← All lessons

Unicode and emoji

Sign in · Sign up

Lesson 4.10

Python stores text as Unicode — one standard for the letters of every language and for emoji:

print("Hello, world")   # English letters are Unicode too
print("🚀")             # an emoji is a character
print(len("🚀"))        # 1

An emoji in code is an ordinary string, so it needs quotes. With len an emoji counts as one character, just like a letter.

The word word and the emoji string icons are set by the check. Print, in order:

  1. the word and its length from len next to it — for example, Hello 5;
  2. the string icons;
  3. the length of the string icons from len.
Hint

An emoji is an ordinary character, but in code it lives in quotes.

len(string) counts characters: a letter and an emoji count as one each, even though an emoji looks wider on screen.