Hey please help me execute this SIMPLE While LOOP in Python 3


#1

I had a question that what would we write (using while loop only) to “input 10 numbers from the user and then output how many of the numbers were less than 0 i.e negative?” I used this sort of program. im getting different errors. If I do it this way it says "Break after Loop". If I put x+=1 after the y= thingy I get some other error. Please help me.

x=0
c=0
while (x<10):
     y= int(input("Number please: "))
if (y<0): c+=1
x+=1 
break     
print(c)

#2

why do you even have a break? I don't see why you would need it

as for this two lines:

if (y<0): c+=1
x+=1

i would place them inside the loop (change the indention)


#3

Thank you so much man. Love you for that <3. Actually im new learning python so I was a little unsure about the indentation in loop thing. Now i understand


#4

everything working as it should now?


#5

Yes it is working perfectly.


#6

A post was split to a new topic: Help with homework


#7

I choice to help you with a problem you where facing, but i don't feel like helping you with all your homework assignments. I split the topic, now someone else can answer if they feel like it.


#8

Tysm bro. Done. I understand it now.


#9