파이썬

문자열 길이 확인 - len()

simstealer 2021. 11. 27. 00:10

사용법

len(object)

len("Life is too short") # 문자열(string)

결과 값 : 17

 

len(['a', 'b', 'c', 'd']) # 리스트(list)

결과 값 : 4

 

len(('a', 'b', 'c', 'd')) # 튜플(tuple)

결과 값 : 4

 

len({'id': 'a', 'pass': 'b'}) # 딕셔너리(dictionary)

결과 값 : 2