Hangman(game) problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Netwatcher
    New Member
    • Sep 2008
    • 58

    Hangman(game) problem

    i have a problem with the following
    (some vaiation of a word quiz game)
    (ignore first group of hashs)
    Code:
    import random
    WordTank=''
    GuessTank=''
    GuessList=12
    GuessWords=['tank','poop','poopster']
    GuessWord=random.choice(GuessWords)
    
    def MajorInputPlace(GuessList,GuessTank,WordTank):
        while 1:
            print 'Please insert your guess below'
            MainInput=raw_input('')
            ###If letters in GuessWord are in WordTank:
            ####print 'you won','The word was',GuessWord
            ####raise SystemExit
            if MainInput!='':
                GuessList=int(GuessList)-int(1)
                for word in MainInput:
                        for i in word:
                            if i in WordTank:
                                if int(WordTank.count(i))< int(GuessWord.count(i)):
                                    WordTank+=i+','
                                else:
                                    pass
                        if word not in GuessWord:
                            if word in GuessTank:
                                pass
                            else:
                                GuessTank+=word+','
                if GuessTank=='':
                    pass
                else:
                    print 'The letters',GuessTank,'Are not in the word'
                if WordTank=='':
                    print WordTank
                else:
                    print 'The letters',WordTank, 'Are in the word'
                while GuessList>0:
                    break
                while GuessList==0:
                    print 'You Failed!'
                    continue
            else:
                print 'NO INPUT'
            print 'You have '+str(GuessList)+' Guesses left!'
    print 'You have '+str(GuessList)+' Guesses left!'
    MajorInputPlace(GuessList,GuessTank,WordTank)
    def Win():
        print 'Congratulations, You have won the game, yeepy :D'
    I am having a problem with this line -'if int(WordTank.co unt(i))< int(GuessWord.c ount(i)):'- i tried few variations, but non-of-them seems to work (
    any suggestions?
    Thank you in advance,
    Netwatcher
    Last edited by Netwatcher; Oct 4 '08, 08:20 AM. Reason: stupid questions
  • Netwatcher
    New Member
    • Sep 2008
    • 58

    #2
    got that one figured =/
    Code:
     if MainInput!='':
                GuessList=int(GuessList)-int(1)
                q=list(MainInput)
                for i in q:
                    if i in GuessWord:
                        if WordTank.count(i)<GuessWord.count(i):
                            WordTank+=i+','
                        else:
                            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....
    Code:
     MainInput=raw_input('')
            pop=list(GuessWord)
            for i in GuessWord:
                pass
            if WordTank.count(i)==GuessWord.count(i):
                print 'VICTORY'
                raise SystemExit
            else:
                pass
    Delet This post please

    Comment

    Working...