Advertisement
JonatasAndrade

WordGuessingCode

Dec 17th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #PlayAgain?
  2.  
  3. TheEnd = "Is_Near"
  4. while TheEnd != "exit":
  5.  
  6. #Presentation
  7. print("\n***GUESS THE WORD*** \n \n First, ask a friend to type a lowercase password \n(and don't dare to peek)")
  8. Password = input("\nType a mean word, Sir!\nPassword(lowercase):")
  9. print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nNow, watch your friend struggling to guess it 8)")
  10.  
  11.  
  12. # Letter_Count - Returns default hint value
  13.  
  14. def Letter_Count(word, letter):
  15. L_Counter = 0
  16. for L in word:
  17. if L == letter:
  18. L_Counter += 1
  19. return L_Counter
  20.  
  21. Try_Counter = 0
  22. Try = "SpamAndEggs"
  23.  
  24. # Code loops until someone inputs the right password.
  25.  
  26. while not Try == Password:
  27.  
  28. #HINTS output code:
  29.  
  30. print("\nEnter a single character to get a hint:")
  31. x = input()
  32. if len(x) != 1:
  33. print("\nI said a SINGLE character!!!")
  34. continue
  35. Try_Counter += 1
  36. print("\nThis character appears {0} times within the secret word" "and takes {1}% of it's size".format(Letter_Count(Password,x),round(100*Letter_Count(Password,x)/len(Password))))
  37.  
  38. #Making more interesting hints
  39. if Password.startswith(x):
  40. print("\nAlso, that is password's first letter! \n")
  41. if Password.endswith(x):
  42. print("\nAlso, that is password's last letter! \n")
  43.  
  44. #GUESS checking code
  45.  
  46. Try = input("Give it a guess: ")
  47. if Try == "42":
  48. print("\nAccording to an ASI from a remote galaxy, Input() == True. \nHowever, this is a crappy Phyton code that is not able to even aknolowedge itself, so...")
  49. if Try != Password:
  50. if Try_Counter >= 25:
  51. print ("\nOkay loser, Password is", Password)
  52. if Try_Counter >= 3:
  53. print ("\nNope, try again. You have missed", Try_Counter ,"times already.")
  54. else :
  55. print ("\nUh... No.")
  56.  
  57. #Ending.
  58.  
  59. if Try_Counter == 1:
  60. print ("\nYou'd better rush to the nearer casino, you lucky bastard!")
  61. else:
  62. print("\nYup, that's right. You can have your cake now.")
  63.  
  64. #Replay?
  65.  
  66. Pacience = 0
  67. while TheEnd != "R":
  68. TheEnd = input("\nEnter 'exit' to... Er, exit. Or type 'R' to replay. \nPlease don't try typing anything else: ")
  69.  
  70. if TheEnd == "exit":
  71. exit()
  72. else:
  73. Pacience += 1
  74. if Pacience == 1:
  75. print("\n*#@&!!")
  76. if Pacience == 2:
  77. print("\nF#@&!!")
  78. if Pacience == 3:
  79. print("\nFoo!!!")
  80. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement