names=["Mr. Kim", "Jadoo", "IU", "Darius", "Hani"]
print(len(names[0]))
I ran it and found 12
What I want is to print out the number of characters in the 0
of the list names
I don't know what's wrong
Obviously, print(names[0])
makes "Kim"
appear well;
What is common sense in the programming industry is: One letter letter is 3 bytes. Therefore, "Kim"
is 12 bytes.
Test the following by running it in multiple environments:
print(len("a") # 1 byte
print(len("̈") # 2 bytes
print(len("A") # 3 bytes
print(len("household") # 3 bytes
print(len("😂") # 4 bytes
print(len("🤷🏻♂️") # 17 bytes (U+1F937 + U+200D + U+2642 + + U+FE0F)
names=["Kim"], "Kim Plum", "IU", "Darius", "Hani"]
print(len(names[0]))
I think the reason why there is 12 in is because Python treats one word in Korean as 3 bits. But I think it's version 3 from the past
If you want to do it with the number of characters,
print(len(names[0])/3)
I think you can do it with that
© 2025 OneMinuteCode. All rights reserved.