I have a program which randomly selects and prints song names and artists from an external text file. I have split the line into an a,b format but the program won't recognize the variable once i answer the question.
file = open("Songz.txt", "r")
lines = file.readlines()
random_lines = random.choice(open("Songz.txt").readlines())
Song = random_lines
a,b=(Song.split(","))
print(a)
print(b)
Answer1 = input().upper()
if Answer1 == b:
print(" Correct ")
Quiz_Score = Quiz_Score + 3
else:
print("incorrect")
Once the code reaches the if Answer1 == b:
section, the code seems to forget what value the variable (b) has. Any ideas why?
Aucun commentaire:
Enregistrer un commentaire