Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- x = random.randint (1, 100)
- count = 0
- def guessing_game():
- print("Let's play a number guessing game!")
- guess = int(input('Guess a number between 1 and 100: ')
- if guess > x:
- print('Too high! Guess again!')
- count = count + 1
- elif guess < x:
- print('Too low! Guess again!')
- count = count + 1
- else:
- print('You guessed the correct number in', count, 'attempts!')
- while guess != x
- return guess
- def main():
- keep_playing == y
- while keep_playing:
- keep_playing != y
- guessing_game()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement