The sum of ten numbers inserted from the user

Joel Goldstick joel.goldstick at gmail.com
Thu Feb 7 06:50:31 EST 2019


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


More information about the Python-list mailing list