Note:
I've been doing this only for practice and NOT for practical reasons, as you can see the output isn't realy HangMan-like and any combination of the right letters will be accepted so please do NOT comment about the funcunallity of the code!
if it DOESseem nice to you then i thank you very much :D
My problem is in the following-

import random
WordTank=''
GuessTank=''
GuessList=12
GuessWords=['aristocrat','householdl','butcher','imagination','convoluted','great','think','house','animal']
GuessWord=random.choice(GuessWords)
def Win(GuessList,GuessWord):
    print 'The word was-','"',GuessWord,'"'
    GuessList+=int(GuessList)*2
    print 'You Won',GuessList,'Points'
    raise SystemExit
def MajorInputPlace(GuessList,GuessTank,WordTank):
    while 1:
      
        print 'Please insert your guess below'
        MainInput=raw_input('')
        p=''
#Problem Starts HERE#
        gp=list(GuessWord)
        if GuessWord in WordTank:
            print 'victory'
            Win(GuessList,GuessWord)
        else:
            pass
#Problem Ends HERE#
        if len(MainInput)>6:
            print 'You can Guess no more then 6 Characters in a Guess'
            continue
        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
            for word in MainInput:
                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=='':
                pass
            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 '\nYou have '+str(GuessList)+' Guesses left!\n'
'\nYou have '+str(GuessList)+' Guesses left!'
MajorInputPlace(GuessList,GuessTank,WordTank)#values change after rounds!#

Literally, what i want is >"if the all the letters in the Word match the letters in the successful letters do whatever"<
any suggestions?
Thank you very much for reading this ;)

Recommended Answers

All 5 Replies

Literally, what i want is >"if the all the letters in the Word match the letters in the successful letters do whatever"<
any suggestions?
Thank you very much for reading this ;)

So I think you are asking how to do this

found = True
for letter in MainInput:
   if letter not in GuessWord:
      found = False
if found:
   print "Your guess is correct"
##
##   If you want to keep track of incorrect letters
incorrect_list = []
for letter in MainInput:
   if letter not in GuessWord:
      incorrect_list.append(letter)
if len(incorrect_list) == 0 :
   print "Your guess is correct"
##
##   you can also simply use "=="
if MainInput.lower() == GuessWord.lower():
if MainInput in GuessWords:

Of course if there are two "a"s in MainInput and one in GuessWord, the first two examples will still give you a positive result. In which case you could delete that letter or just replace a guessed letter with "*" which would solve the problem.

P.S. If the code is an exact copy of your program, 'householdl' is misspelled (and how do you spell mis-spelled?)

lol... i they were two rude words so i changed 'em fast just to post it here... don't worry lol
NOT for letter in main input but For letter in GuessWord(wich is the chosen word, i did called them in weird names that have nothing to do with what that Var contains=\ it helps me to remember them
(...) Oo
and-
i used that same method u used for the incorrect list (aka GuessTank)! i just need the letters to be presented to the user and i don't like the brackets that the list obj shows.
and... i didn't use the lower() function because i need the sesitivity for later.
Bottom line! read first
i need find if the letters in the given word are already!!! in the WordTank!!!!
any suggestions?
(i'm practicing, so "easy" tasks like == aren't realy what i'm looking for, looking for all the letters IN a word to match be found in the succesfull tries (maybe i need to play with the length?)) (were these just normal brackets in brackets? oh crap... i'm being affected by programming
wooo....

oMg, i did have to tranform all the Quotes to brackets !!!! NOOOOO!!!!
but then, because of the way my code is built, only this little line will do the trick:

if len(GuessWord)==len(WordTank):
            Win()

it just hit me, been on that little bug all day long!!!
(and yes, i put this one down so it will happen after a letter is appended to the dict,
using += to add to dict is my way of doing it)


Thank You.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.