August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 17 | Endgame |
| 1: | avengers = ['Bruce', 'Carol', 'Natasha', 'Tony'] |
| 2: | idx = 3 |
| 3: | avengers[idx], idx = 'Peter', 2 |
| 4: | print(avengers) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: [’Bruce’, ’Carol’, ’Natasha’, ’Peter’]
You’re doing multiple assignments, also known as unpacking. In line 3, Python will first evaluate the right side of the = from left to right and then ...
Read now
Unlock full access