dimanche 19 juin 2016

Python Shuffle Word Input Always Incorrect

import random
while True:
    word=random.choice(open("words.txt","r").readlines())
    print(word)#------Used for debugging
    scramble=list(word)
    random.shuffle(scramble)
    scramble="".join(scramble)
    if scramble!=word:
        print(scramble.replace("\n",""))
        guess=input("|")
        if guess==word:
            print("Correct")
        else:
            print("Incorrect")

When I type in the correct answer on this shuffle game, the input is always wrong for some reason. "words.txt" is simply a text file with a word for every line.




Aucun commentaire:

Enregistrer un commentaire