A simple number guessing game code written in Python

From , 5 Years ago, written in Python, viewed 94 times.
URL https://pastebin.vip/view/55a0ce82
  1. import random
  2.  
  3. guesses_made = 0
  4.  
  5. name = raw_input('Hello! What is your name?\n')
  6.  
  7. number = random.randint(1, 20)
  8. print 'Well, {0}, I am thinking of a number between 1 and 20.'.format(name)
  9.  
  10. while guesses_made < 6:
  11.  
  12.     guess = int(raw_input('Take a guess: '))
  13.  
  14.     guesses_made += 1
  15.  
  16.     if guess < number:
  17.         print 'Your guess is too low.'
  18.  
  19.     if guess > number:
  20.         print 'Your guess is too high.'
  21.  
  22.     if guess == number:
  23.         break
  24.  
  25. if guess == number:
  26.     print 'Good job, {0}! You guessed my number in {1} guesses!'.format(name, guesses_made)
  27. else:
  28.     print 'Nope. The number I was thinking of was {0}'.format(number)
  29. #//python/8385

Reply to "A simple number guessing game code written in Python"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website