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
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.
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
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
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:
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:
>>
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')
>
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
:
> 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
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,
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
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
12 matches
Mail list logo