Connecting Tech Pros Worldwide Help | Site Map

Hangman(game) problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 4th, 2008, 07:30 AM
Member
 
Join Date: Sep 2008
Location: Currently in the U.S- carlsbad NM
Age: 17
Posts: 58
Default Hangman(game) problem

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

Last edited by Netwatcher; October 4th, 2008 at 08:20 AM. Reason: stupid questions
Reply
  #2  
Old October 4th, 2008, 03:49 PM
Member
 
Join Date: Sep 2008
Location: Currently in the U.S- carlsbad NM
Age: 17
Posts: 58
Default

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
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.