Advertisement
brilliant_moves

GuessingNumber.py

Feb 3rd, 2016
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1.  
  2. '''
  3. Write a function called guessNum(num). This function will play "guess the number" with the user.
  4.  
  5. The number should be set to 60. Users will keep inputting numbers until 5 tries.
  6. The values are passed as arguments to the function.
  7. If the user guesses the number by the 5th try print "You won", if not print "You lost".
  8.  
  9. '''
  10.  
  11. def guessNum(num):
  12.     for w in range(0,5):
  13.         guess = int (input ("Guess the number: "))
  14.         if guess == num:
  15.             print ("You won")
  16.             return
  17.     print ("You lost")
  18.  
  19. def main():
  20.     guessNum(60)
  21.  
  22. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement