November 14th, 2013, 11:31 PM
Help With While Loops?
I'm making this program for school that involves while loops, and I can't figure out how to do them. Can anyone please explain them to me? Here is what I have to make the program do:
The program must continuously ask the user to enter numbers. When the user enters 0, the program will stop asking for numbers and will then give the user the sum and the average of all the numbers they entered.
How would I go about making a program like this using while loops and if statements? I'm still pretty new to Python so you will have to explain this to me very simply and clearly. Thanks so much for your help!
November 15th, 2013, 02:19 AM
Here is a small tutorial on while loops.
Experiment with them. Try to set one up to end on a certain input. I'm afraid you won't get much more help without a little more demonstrable effort.
Last edited by Mekire; November 15th, 2013 at 02:30 AM.
November 16th, 2013, 08:18 PM
The "standard" way to get input with Python.
num = -1
while num != 0:
input_num = raw_input("Enter a number ")
num = int(input_num)
print "\n*****Enter numbers only*****\n"
Comments on this post
November 17th, 2013, 05:52 PM
Alright, I figured it out. Thanks, guys!