Python 3 | Code Challenges: Loops (8/11) | "Over 9000"

This code should output “9020” but its output is “19020”. I can’t figure out where the extra ten thousand is coming from.
It’s clear that a mistake in this exercise should add an extra five thousand to the output… but why in the world is it an extra ten thousand? I just can’t get my head around it. Somewhere, that five thousand must be doubling up, but I can’t spot where it’s happening.

Instructions, hint, code, and output:
while version:

if version:

You can trace the values if you add a print statement after each sum. You may benefit as well from tracking the list length as you go. Also, you don’t need the elif lst == [] statement.

2 Likes