Re: The sum of ten numbers inserted from the user

2019-02-09 Thread Terry Reedy
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 en

Re: The sum of ten numbers inserted from the user

2019-02-09 Thread Christian Gollwitzer
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.

Re: The sum of ten numbers inserted from the user

2019-02-08 Thread ^Bart
x = 0 for jnk in range(10): x += int(input("Enter a number: ") print(x) It works, there's a missed ) A colleague did: total=0 for n in range(10): n= int(input("Enter a number: ")) total=total+n print(total) I understood your code is more clean! ^Bart -- https://mail.pytho

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Grant Edwards writes: > On 2019-02-07, Ben Bacarisse wrote: >> Ian Clark writes: >> >>> This is my whack at it, I can't wait to hear about it being the wrong big o >>> notation! >>> >>> numbers=[] >>> >>> while len(numbers) < 10: >>> try: >>> chip = int(input('please enter an intege

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Bart writes: > On 07/02/2019 20:45, Ben Bacarisse wrote: >> Ian Clark writes: >> >>> This is my whack at it, I can't wait to hear about it being the wrong big o >>> notation! >>> >>> numbers=[] >>> >>> while len(numbers) < 10: >>> try: >>> chip = int(input('please enter an integer:

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Grant Edwards
On 2019-02-07, Ben Bacarisse wrote: > Ian Clark writes: > >> This is my whack at it, I can't wait to hear about it being the wrong big o >> notation! >> >> numbers=[] >> >> while len(numbers) < 10: >> try: >> chip = int(input('please enter an integer: ')) >> except ValueError: >>

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Ian Clark writes: > This is my whack at it, I can't wait to hear about it being the wrong big o > notation! > > numbers=[] > > while len(numbers) < 10: > try: > chip = int(input('please enter an integer: ')) > except ValueError: > print('that is not a number, try again') >

RE: The sum of ten numbers inserted from the user

2019-02-07 Thread Schachner, Joseph
removed. --- Joe S. From: Ian Clark Sent: Thursday, February 7, 2019 1:27 PM To: Schachner, Joseph Cc: python-list@python.org Subject: Re: The sum of ten numbers inserted from the user This is my whack at it, I can't wait to hear about it being the wrong big o notation! numbers=[] whil

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ian Clark
: > sum += y > > print( "The sum is: ", sum) > > > > -Original Message- > From: ^Bart > Sent: Thursday, February 7, 2019 6:30 AM > To: python-list@python.org > Subject: The sum of ten numbers inserted from the user > > I thought something l

RE: The sum of ten numbers inserted from the user

2019-02-07 Thread Schachner, Joseph
ist: sum += y print( "The sum is: ", sum) -Original Message- From: ^Bart Sent: Thursday, February 7, 2019 6:30 AM To: python-list@python.org Subject: The sum of ten numbers inserted from the user I thought something like it but doesn't work... for n in range(1,

Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Joel Goldstick
On Thu, Feb 7, 2019 at 6:31 AM ^Bart 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

The sum of ten numbers inserted from the user

2019-02-07 Thread ^Bart
I thought something like it but doesn't work... for n in range(1, 11): x = input("Insert a number: ") for y in range(x): sum = y print ("The sum is: ",y) -- https://mail.python.org/mailman/listinfo/python-list