git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# The sum of ten numbers inserted from the user

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

On Thu, Feb 7, 2019 at 6:31 AM ^Bart <gabriele1NOSPAM at hotmail.com> wrote: > > I thought something like it but doesn't work... > > for n in range(1, 11): > x = input("Insert a number: ") The above, keeps replacing x with each input value. You don't want that. Think about appending the input value to a list > > for y in range(x): > sum = y > Here again you are replacing sum with each value of y. And think further about what the value of y is for each iteration. > print ("The sum is: ",y) You should really be asking this sort of question in the python-tutor mailing list. You should also use print function in your loops to learn what is really going on. > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays

- Prev by Date:
**The sum of ten numbers inserted from the user** - Next by Date:
**timezones** - Previous by thread:
**The sum of ten numbers inserted from the user** - Next by thread:
**The sum of ten numbers inserted from the user** - Index(es):