■ len 함수를 사용해 객체(문자열)의 길이(문자 개수)를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
string = "this is a test string" print(len(string)) list = ['unicorn', 'cyclops', 'fairy', 'elf', 'dragon', 'troll'] print(len(list)) map = { 'Batman' : 'Joker', 'Superman' : 'Lex Luthor', 'Spiderman' : 'Green Goblin' } print(len(map)) """ 21 6 3 """ |