โ ๐ Python World
๐ Word Ruler
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
Functions return answers
A function is a tiny machine: it receives inputs, works something out, then returns one answer for the tests to check.
๐ก Hint ladder
- len(word) measures a word.
- List comprehension: [len(w) for w in words]
๐งช Coach checks
- โฏ hi there
- โฏ empty list
- โฏ three words
Live coach
Getting ready
โโโ
๐ฌ A list comprehension builds a new list from an old one in one line.
words = ["hi", "there"]
print([w.upper() for w in words]) # ['HI', 'THERE']
print([w[0] for w in words]) # ['h', 't']
print(len("there")) # 5
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?