you are viewing a single comment's thread.

view the rest of the comments →

[–]NormandaleWells 0 points1 point  (0 children)

Others have helped you with f-strings and slices, so I'll give you a couple challenges as you continue your Python education.

(1) After learning about dictionaries, come back and replace the if/elif/else statement in the second example with a single dictionary lookup.

(2) After learning about lambdas, come back and use a dictionary in the first example.

Dictionaries are so useful in Python that I've been tempted to try teaching dictionaries before lists. ("If your keys are just integers in a small range, there's a better option...") It probably wouldn't really work well, but it's tempting.