Advertisement
ragrwal

Wheel of Fortune

Jun 8th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.82 KB | None | 0 0
  1. word = 'bee'
  2.  
  3. wordlen = len(word)
  4.  
  5. currentstring = ('')
  6. print(wordlen)
  7.  
  8. stars = "****************************************************"
  9. gameover = False
  10. regex = ('%.' + str(wordlen) + 's')
  11. currentstring = regex % stars
  12. numtries = 5
  13. print(currentstring)
  14.  
  15. #inputletter = input('What letter would you like to add ')
  16.  
  17. def checkforletter(inputletter):
  18.     global currentstring
  19.     numberofcharacters =  0
  20.     for i in range(wordlen):
  21.         letterofword = word[i]
  22.         if inputletter == letterofword:
  23.             #currentstring = (
  24.             currentstring = currentstring[:i] + inputletter + currentstring[i+1:]
  25.             numberofcharacters = numberofcharacters + 1
  26.             print(numtries)
  27.         else:
  28.             #continue
  29.             #numtries = numtries - 1
  30.             #print('There are no' + inputletter + "s in the word")
  31.             continue#print('You have ' + str(numtries) + ' remaining')
  32.     return numberofcharacters
  33.    
  34.    
  35. while gameover == False:
  36.     if numtries != 0:
  37.        
  38.    
  39.         #print word
  40.         gorf = input('Would you like to guess a letter, or try to guess the full word? ')
  41.         if gorf == 'guess':
  42.             print('You have ' + str(numtries) + ' guesses remaining')
  43.             inputletter = input('What letter would you like to guess')
  44.             if len(inputletter) == 1 and inputletter.isalpha() == True:
  45.                 lol  = checkforletter(inputletter)
  46.                 if lol > 0:
  47.                     print('There are ' + str(lol) + str(inputletter) + "'s in the word!")
  48.                     print(currentstring)
  49.                     if currentstring == word:
  50.                         print('You won')
  51.                         gameover = True
  52.                     continue
  53.  
  54.                 if lol == 0:
  55.                     numtries = numtries - 1
  56.                     print('There are no ' + inputletter + "'s in the word'")
  57.                     print('You have ' + str(numtries) + ' remaining')
  58.                    
  59.                     continue
  60.  
  61.             else:
  62.                 numtries = numtries - 1
  63.                 print('That was not a correct input')
  64.                 print('You have ' + str(numtries) + ' remaining')
  65.  
  66.         if gorf == 'full':
  67.             guessword = input('Guess the word, If you get it wrong, the game will be over: ')
  68.             if guessword == word:
  69.                 print('You won')
  70.                 gameover = True
  71.             else:
  72.                 numtries = 0
  73.     if numtries == 0:
  74.         print('You lost')
  75.  
  76.         gameover = True
  77.         #print('hello')
  78.         continue
  79.        
  80.                    
  81.                
  82.  
  83. print('endofcode')        
  84.         #if full
  85.         #hfaufhafhajsdfhalsjdfhaslkjfhdaskjfahsdkjfhaksjfhda
  86.         #else
  87.              #try again.
  88.  
  89. #*/
  90.  
  91.  
  92. #print(bruh.replace(bruh[0],'d'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement