강의

멘토링

커뮤니티

Inflearn Community Q&A

nomorerest92259979's profile image
nomorerest92259979

asked

Free Python Tutorial (Basic) - Become a Developer in 6 Hours

one line for

반복문과는 다른 질문인데 자동형변환이 되나요?

Written on

·

175

0

name = ["Iron Man""Thor""Captin America"]
nameLen = {len(j) for j in name}
print(nameLen)
결과값이 {8, 4, 14} 이던데
자료구조가 List에서 set으로 자동으로 바뀐건가요?
python

Answer 1

0

[]는 list형 자료구조, {}는 set형 자료구조에 사용됩니다.

자료구조가 자동으로 바뀐게 아니라, 2번째 줄에서 nameLen의 값을 할당할 때 {} set형에 담아서 그렇습니다.

nomorerest92259979's profile image
nomorerest92259979

asked

Ask a question