Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Xuan Wen
- #A01045836
- import random
- def user_input():
- user_input = int(input('Make a guess:'))
- return user_input
- def right_answer():
- the_num = random.randint(1, 100)
- return the_num
- def compare():
- count = 1
- input_num = user_input()
- answer = right_answer()
- while input_num != answer and count < 7:
- if input_num > 100 or input_num < 1:
- print('Too bad! The number chosen was', answer)
- break
- else:
- while count < 7:
- if input_num < answer:
- print('Too Low!!')
- elif input_num > answer:
- print('Too high!!')
- else:
- count = count + 1
- break
- count = count + 1
- input_num = user_input()
- print('Run out of guesses. The number chosen was', answer)
- if input_num == answer:
- print('Well done! You found the number in', count, 'times.')
- def main():
- compare_num = compare()
- main()
Add Comment
Please, Sign In to add comment