#### Function secondLoop has the same components with the additional lines #
        number = len(sentence)
        while number != 0 #While flag==True
        letter = input("Enter letter: ")
            # letter is asked in function again
            if letter not in enteredLetters:
                find = sentence.find(letter)
                if find == -1:
                    print("Letter is not in word")
            # flag = False
            enteredLetters,newSentence,lettersInWord = secondLoop(enteredLetters,sentence,newSentence,lettersInWord)
                    newSentence = ""
                    for char in sentence:
                        if char in lettersInWord:
                            newSentence = newSentence + char 

                            newSentence = newSentence + "_ "
             number = newSentence.count("_")
             #flag = True

            elif letter in enteredLetters:
                print ("The letter has been used")
                #flag = False
        enteredLetters,newSentence,lettersInWord = secondLoop(enteredLetters,sentence,newSentence,lettersInWord

        print (newSentence)

This is a guess game that changes between two players and when it changes to second player it doesnt work for some reason. Any ideas why

A guess would be that "newSentence" is used in both loops so contains only the value from the last loop. Or in
number = len(sentence)
"sentence" is not initialized and still has a length of zero.
Convert this code to a function and pass each player's correct-letters-guessed list and the to be guessed word to the function, returning the new list. Note that "in enteredLetters" should not be necessary as "in newSentence" will give the same result. For further assistance be more specific about what "it doesn't work" means.

This article has been dead for over six months. Start a new discussion instead.