Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- run = True
- second_chance = True
- def main():
- global attempt
- print('What is the lowest number of attempts do you think it will take you to guess my number between 1-100?')
- print('Lets give it a try?')
- print()
- game()
- attempts()
- prev_score = []
- def game():
- import random
- attempt = 0
- prev_score = 0
- comp_number = random.randint(1, 100)
- while run:
- player_number = int(input('Enter number: '))
- if player_number == comp_number:
- print(f'Wow that was my number! You did it in {attempt} attempts!')
- attempt += 1
- break
- elif player_number < comp_number:
- attempt += 1
- print('Your number is too low, try again.')
- elif player_number > comp_number:
- attempt += 1
- print('Your number is too high, try again.')
- if prev_score < attempt:
- print('Your last attempt was better, keep trying and maybe you will get better :P')
- elif prev_score > attempt:
- print('Nice job! You beat your previous score!')
- elif prev_score == attempt:
- print('Well you tied your previous score. Keep trying!')
- print()
- another_game()
- def another_game():
- while second_chance:
- print('Would you like to try and lower your score?')
- play_again = input("Type 'yes' to continue, or 'no' to give up: ")
- if play_again == 'no' or 'No':
- print('Are you sure you want to give up?')
- give_up = input("Type 'yes' to quit: ")
- if give_up == 'yes' or 'Yes':
- exit()
- else:
- return main()
- sec_chance()
- print()
- main()
Advertisement
Add Comment
Please, Sign In to add comment