The sum of ten numbers inserted from the user
Terry Reedy
tjreedy at udel.edu
Sat Feb 9 14:18:32 EST 2019
On 2/9/2019 4:23 AM, Christian Gollwitzer wrote:
> 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.
It is not as bad as "int = int(input('Number? '))"
--
Terry Jan Reedy
More information about the Python-list
mailing list