dict.fromkeys(iterable, value=None)는 주어진 iterable의 요소를 키로 하는 딕셔너리를 생성하는 메서드.
기본적으로 값은 None이지만, 다른 값으로 설정할 수도 있음.
my_string = "banana"
unique_chars = dict.fromkeys(my_string)
print(unique_chars) # {'b': None, 'a': None, 'n': None}
👉 이걸 보면, dict.fromkeys(my_string)는 중복을 제거하면서 문자열의 순서를 유지한 딕셔너리를 만듦
👉 ''.join(dict.fromkeys(my_string))를 사용하면 중복 제거 + 순서 유지된 문자열을 얻을 수 있다.
my_string = "banana"
result = ''.join(dict.fromkeys(my_string))
print(result) # "ban"