

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Type Hints
incomplete
2: Basic Types
incomplete
3: Function Parameters
incomplete
4: Return Types
incomplete
5: Fixing Type Hints
incomplete
6: List and Set Hints
incomplete
7: Dictionary Hints
incomplete
8: Tuple Hints
incomplete
9: Specific Container Types
incomplete
10: Nested Types
incomplete
11: Optional Values
incomplete
12: Fix Code With Type Hints
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
It's possible to type-hint a container with just the container type:
items: list = ["Black Firebomb", "Titanite Chunk"]
This says items is a list, but it doesn't tell us what kind of values go inside! Assuming you know what's inside, best to be specific:
items: list[str] = ["Black Firebomb", "Titanite Chunk"]
That said, bare container type hints aren't wrong. Sometimes you really don't know what types of values a container will hold, or the specific type hint would be too complicated to be useful. You'll see that occasionally with dicts. Just give clear type hints whenever possible!
Fantasy Quest's reward summary function already has type hints, but some of the container types are too vague. Make the container type hints more specific.
Notice that before you add the hint, the first_item variable's type tooltip is "Unknown." After you add the hint, Python can infer that first_item is a str because it's in the items list.
Don't change the function body.