By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,046 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,046 IT Pros & Developers. It's quick & easy.

Hangman(game) problem

P: 58
i have a problem with the following
(some vaiation of a word quiz game)
(ignore first group of hashs)
Expand|Select|Wrap|Line Numbers
  1. import random
  2. WordTank=''
  3. GuessTank=''
  4. GuessList=12
  5. GuessWords=['tank','poop','poopster']
  6. GuessWord=random.choice(GuessWords)
  7.  
  8. def MajorInputPlace(GuessList,GuessTank,WordTank):
  9.     while 1:
  10.         print 'Please insert your guess below'
  11.         MainInput=raw_input('')
  12.         ###If letters in GuessWord are in WordTank:
  13.         ####print 'you won','The word was',GuessWord
  14.         ####raise SystemExit
  15.         if MainInput!='':
  16.             GuessList=int(GuessList)-int(1)
  17.             for word in MainInput:
  18.                     for i in word:
  19.                         if i in WordTank:
  20.                             if int(WordTank.count(i))< int(GuessWord.count(i)):
  21.                                 WordTank+=i+','
  22.                             else:
  23.                                 pass
  24.                     if word not in GuessWord:
  25.                         if word in GuessTank:
  26.                             pass
  27.                         else:
  28.                             GuessTank+=word+','
  29.             if GuessTank=='':
  30.                 pass
  31.             else:
  32.                 print 'The letters',GuessTank,'Are not in the word'
  33.             if WordTank=='':
  34.                 print WordTank
  35.             else:
  36.                 print 'The letters',WordTank, 'Are in the word'
  37.             while GuessList>0:
  38.                 break
  39.             while GuessList==0:
  40.                 print 'You Failed!'
  41.                 continue
  42.         else:
  43.             print 'NO INPUT'
  44.         print 'You have '+str(GuessList)+' Guesses left!'
  45. print 'You have '+str(GuessList)+' Guesses left!'
  46. MajorInputPlace(GuessList,GuessTank,WordTank)
  47. def Win():
  48.     print 'Congratulations, You have won the game, yeepy :D'
I am having a problem with this line -'if int(WordTank.count(i))< int(GuessWord.count(i)):'- i tried few variations, but non-of-them seems to work (
any suggestions?
Thank you in advance,
Netwatcher
Oct 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: 58
got that one figured =/
Expand|Select|Wrap|Line Numbers
  1.  if MainInput!='':
  2.             GuessList=int(GuessList)-int(1)
  3.             q=list(MainInput)
  4.             for i in q:
  5.                 if i in GuessWord:
  6.                     if WordTank.count(i)<GuessWord.count(i):
  7.                         WordTank+=i+','
  8.                     else:
  9.                         pass
now how do i check if all the words in a certine list are in a string?


Edit:
oh crap... seems like i don't need help anyways....
Expand|Select|Wrap|Line Numbers
  1.  MainInput=raw_input('')
  2.         pop=list(GuessWord)
  3.         for i in GuessWord:
  4.             pass
  5.         if WordTank.count(i)==GuessWord.count(i):
  6.             print 'VICTORY'
  7.             raise SystemExit
  8.         else:
  9.             pass
  10.  
Delet This post please
Oct 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.