mercredi 20 septembre 2017

Same input 2 different results

I'm extremly new to programming but would really like some help. I'm trying to make a game where 2 players need to input words based on the last 2 letters of the word the other player placed into. I got that part to work but can't seem to get the part which decides the winner. It's the same 2 elif statements but they should print out different results.

used_words=[]

while True:
player_one=raw_input("Player one \n")
first= list(player_one)
player_two=raw_input("Player two \n")
second=list(player_two)

if first[-2:] == second[:2] and first and second not in used_words:
    used_words.append(player_one)
    used_words.append(player_two)
    continue


elif first[-2:] != second[:2]:
    print "Player one wins! \n"
    print "The word you had to match was: ", second
    break



elif second[:2] != first[-2:]:
    print "Player two wins!"
    print "The word you had to match was: ", first
    break


else:
    break

Aucun commentaire:

Enregistrer un commentaire