Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Intro (Imports randint function, prints out introductions)
- import random
- print ('There are three primary colours - red. yellow, and blue. You will have 2 guesses.')
- print ('But firstly, let us start with your name')
- name = input()
- a = ['red', 'yellow', 'blue']
- secretColour = random.choice(a)
- print ('Hello, ' + name + ', guess which is it - red, yellow, or blue')
- #Colour guessing part. Creates a for loop. Break ends the loop after 2 incorrect guesses, or a correct guess.
- for guessesTaken in range(1, 3):
- print('Take a guess.')
- guess = int(input())
- if guess == str(secretColour):
- print('That is a number, silly.')
- elif guess != secretColour:
- print(' That is not it, chief.')
- else:
- break #Due to only 3 choices, we're not giving out hints like we would with a 1-10 guessing game
- if guess == secretColour:
- print ('Looks like you ,' + name + ', are correct. It really was' + str(secretColour) + '!')
- else:
- print('It was ' + str(secretColour) + ', actually.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement