N
Nathan Pinno
Hi all,
What's wrong with the following code? It says there is name error, that
random is not defined. How do I fix it?
# Plays the guessing game higher or lower.
# Originally written by Josh Cogliati, improved first by Quique, then by
Nathan Pinno.
print "Higher or Lower"
print
number = random.choice(range(100))
guess = 0
while guess != number:
guess = input("Guess a number: ")
if guess > number:
print "Too high"
guess = input("Guess a number: ")
elif guess < number:
print "Too low"
guess = input("Guess a number: ")
print "Just right"
Thanks.
Nathan Pinno
http://www.npinnowebsite.ca/
What's wrong with the following code? It says there is name error, that
random is not defined. How do I fix it?
# Plays the guessing game higher or lower.
# Originally written by Josh Cogliati, improved first by Quique, then by
Nathan Pinno.
print "Higher or Lower"
number = random.choice(range(100))
guess = 0
while guess != number:
guess = input("Guess a number: ")
if guess > number:
print "Too high"
guess = input("Guess a number: ")
elif guess < number:
print "Too low"
guess = input("Guess a number: ")
print "Just right"
Thanks.
Nathan Pinno
http://www.npinnowebsite.ca/