Skip to content

Instantly share code, notes, and snippets.

@TammyLaforest
Created February 16, 2019 03:23
Show Gist options
  • Save TammyLaforest/c94fd83b5fe6ce80fc13ac0af04dd6f1 to your computer and use it in GitHub Desktop.
Save TammyLaforest/c94fd83b5fe6ce80fc13ac0af04dd6f1 to your computer and use it in GitHub Desktop.
MotionlessGlossyComma created by TammyLaforest - https://repl.it/@TammyLaforest/MotionlessGlossyComma
# Improved code
import random
first = 1
last = 10
number = random.randint(first, last)
guess = int(input("Enter a number from " + str(first) + " to " + str(last) +": "))
while number != guess:
if guess < number:
print("guess is low")
first=guess
guess = int(input("Enter a number from " + str(first) + " to " + str(last) +": "))
elif guess > number:
print("guess is high")
last=guess
guess = int(input("Enter a number from " + str(first) + " to " + str(last) +": "))
print("You guessed it!")
print("Click RUN to play again.")
# old code
import random
number = random.randint(1, 10)
guess=int(input('Pick a number from 1 to 10: '))
while number != guess:
if guess < number:
print("guess is low")
guess=int(input('Pick a number from 1 to 10: '))
elif guess > number:
print("guess is high")
guess=int(input('Pick a number from 1 to 10: '))
print("You guessed it!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment