The idea
A locker number can be a label or a quantity, depending on your task. Joining "12" and "3" makes "123". Adding 12 and 3 makes 15. input() returns text—even when the reader enters digits. Convert it with int() if you need a whole number. Here the playground supplies input from its Input lines box: put one answer on each line before Run.
A tiny experiment
answer = input("How many clues? ")
clues = int(answer)
print(clues + 1)
print(7 / 2)
print(7 // 2)
print(7 % 2)Prepared input for this example: 3. The playground supplies it when input() asks.
Reveal the expected output
How many clues? 4 3.5 3 1
Read it one step at a time
- With input 3, int converts the text to an integer and the first calculation produces 4. The prompt appears before that result.
- / gives ordinary division. For these positive numbers, // gives the whole-number quotient.
- % gives the remainder: 7 contains three groups of 2, with 1 left over.
Make one change
Keep the input as 3, but change all three 7s to 8. What changes?
Check your thinking
The division results become 4.0 and 4; the remainder becomes 0.
Keep following the trail
Sources & further reading
Companion notes for Coding Adventure by James Colby. Historical claims link to their sources; the examples are written for this learning trail.