I am trying to learn Python and was looking over for loops and while loops.
Should the following be using a while loop as it is waiting for user input?
When the 5 numbers have been selected, how do I print what has been randomly selected at the end?
import random
low = ['1', '2', '3', '4', '5']
high = ['10', '20', '30', '40', '50']
print "Please Enter Low or High"
print "Press 1 for Low"
print "Press 2 for High"
print
count = 0
for number in range (5):
choice = raw_input ("Low or High: ")
if choice == '1':
choice = random.choice(low)
count = count + number
print choice
elif choice == '2':
choice = random.choice(high)
count = count + number
print choice
Should the following be using a while loop as it is waiting for user input?
When the 5 numbers have been selected, how do I print what has been randomly selected at the end?
import random
low = ['1', '2', '3', '4', '5']
high = ['10', '20', '30', '40', '50']
print "Please Enter Low or High"
print "Press 1 for Low"
print "Press 2 for High"
count = 0
for number in range (5):
choice = raw_input ("Low or High: ")
if choice == '1':
choice = random.choice(low)
count = count + number
print choice
elif choice == '2':
choice = random.choice(high)
count = count + number
print choice