lundi 30 novembre 2020

String list from a txt file doesn't recognize other word as the same when i compare it

I'm making a game where you get a lyric and you have to guess the artist or the song. The thing is that when I try to see if the input of the player is in the list where the Artist and song are located just doenst works, i tried it with the same words but python just tell print me "no" every time.

This is just a part of big code so if something doesn't make sense is because I write it in a way that you could understand what I want to do:

def reading(file, lycris, artistandsong): 
    firstline = file.readline()
    artistandsong=(firstline.split(";"))
    return artistandsong

file=open("E:\\Documents\\TP IP 2do 2020\\letras\\1.txt","r")
lycris=[]
artistandsong=[]
wordsfromuser=[""]
artist=reading(file,lycris,artistandsong)

for word in artist:
    if word in wordsfromuser:
     print("yes")
    else:
     print("no")
file.close()

I have also tried if word == words

Aucun commentaire:

Enregistrer un commentaire