repl.it
@anonymous/

ImmaterialMediumforestgreenTurkey

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random


#select a random number
myNumber = random.randint(1, 20)
guesses = []
def game():
	guess = input("Guess a number and put here : ")	
	#loop for the game
	while len(guesses) <= 5:
		try:
			guess = int(input("Guess a number and put here : "))
		except ValueError:
			print("not a number {}".format(guess))
		else:
			if not guess in range(1, 20):
				print('Put only number between 1 - 20')
				continue
			elif guess == myNumber:
				print("Great! Your guess is matched with me")
				continue
				chance()
			else: 
				print("Bummer! Try again with a different number.")
			guesses.append(guess)
	else: 
		print("Woh hu! You didn't get me. My number was {}".format(myNumber))
		chance = str(input("Wan't to try again? Y/n "))
		if chance.lower() != 'n':
			game()
		else:
			print('Bye! Bye!')
game()
Fetching token
?