Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mchirico/4e9351901ae1119b6d71525fe9c57cff to your computer and use it in GitHub Desktop.
Save mchirico/4e9351901ae1119b6d71525fe9c57cff to your computer and use it in GitHub Desktop.
Guess.py
import random
numberOfGuesses = 0;
mysteryNumber = random.randint(1, 10)
while numberOfGuesses < 3:
guessUser1 = int(input("User1: Guess a number between 1-10: "))
if guessUser1 < 0 or guessUser1 > 10:
print("Hey! That is an invalid number. You lost your turn. ")
if guessUser1 == mysteryNumber:
print("You win!")
break
if guessUser1 >= mysteryNumber:
print("Your guess is too high!")
if guessUser1 <= mysteryNumber:
print("Your guess is too low!")
guessUser2 = int(input("User2: Guess a number between 1-10: "))
if guessUser2 < 0 or guessUser2 > 10:
print("Hey! That is an invalid number. You lost your turn. ")
if guessUser2 == mysteryNumber:
print("You win!")
break
if guessUser2 >= mysteryNumber:
print("Your guess is too high!")
if guessUser2 <= mysteryNumber:
print("Your guess is too low!")
numberOfGuesses = numberOfGuesses+1
print("This is guess ", numberOfGuesses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment