Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions randomNumbers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import random

bottom = int(raw_input('\nWhat is the bottom number in your range?\n> '))
top = int(raw_input('\nWhat is the top number in your range?\n> '))

while __name__ == '__main__':
print '\n' * 25
print random.randint(bottom, top)
raw_input('\nPress Enter for another.')
from random import randint
print("Hello the game begins")
number = randint(0,20)
attempt = 3
def trying():
try:
global attempt
userNumber = input("Nubmer: ")
if int(userNumber) > number and attempt > 1:
attempt = attempt - 1
print("You have a " + str(attempt) + " attempts")
print("Try a smaller number")
trying()
elif int(userNumber) < number and attempt > 1:
attempt = attempt - 1
print("You have a " + str(attempt) + " attempts")
print("Try a bigger number")
trying()
elif int(userNumber) == number and attempt > 1:
input("You win!")
else:
print("Game over\nThe number is ",number)
except ValueError:
print("ERROR. Try again please")
trying()