The sum of ten numbers inserted from the user

Christian Gollwitzer auriocus at gmx.de
Sat Feb 9 04:23:05 EST 2019


Am 08.02.19 um 09:58 schrieb ^Bart:
> A colleague did:
> 
> total=0
> for n in range(10):
> 
>      n= int(input("Enter a number: "))

Here, you are reusing "n" for two different things:
1. The loop index, indicating which number you ask for
2. The number entered from the user

This is avery bad thing.

	Christian




More information about the Python-list mailing list