git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The sum of ten numbers inserted from the user


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