Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import the random library
- import random
- # read a score from the keyboard
- print("I am thinking of a number between 1-10")
- print("Try to guess the number [1-10]", end="")
- userGuess = int(input())
- # have the computer randomly pick a number from 1-10
- computerNumber = random.randint(1, 10)
- if userGuess == computerNumber:
- if userGuess == 2:
- userGuess = "Jack"
- print("You guessed " + str(userGuess) + " and I picked " + str(computerNumber) + ". Nice Job!") #added concatentation to not have the space before the period
- else:
- print("\nNope, the number was", computerNumber, "and you guessed", userGuess)
Advertisement
Add Comment
Please, Sign In to add comment