I'm working on my NEA assessment and I can't seem to fix this bit of code here. The code provides the artist name (in this case BTS) and the first initial of a song (F for Fire). When I type Fire, it comes up as incorrect.
Not entirely sure what to write for background here. This is my first time trying this on Python. I've tried minor alterations here but to no avail.
file = open("artistname.txt", "r")
artist = file.readline()
file.close()#opens file, reads it into artist variable and closes
file = open("songName.txt", "r")
song = file.readline()
file.close()#opens file, reads it into song variable and closes
score = 0
for round in range(len(artist)):
print(artist)
songInitial = song[:1]
print(songInitial)#prints first initial
if input() == song:
print("Correct: +3 points")
score = score + 3#adds 3 to score
print("Score = ", score)#prints score
else:
print("Incorrect, try again")
if input() == song:#allows second chance
print("Correct: +1 point")
score = score + 1#adds 1 to score
print("Score = ", score)#prints score
else:
print("Incorrect, game over.")
print("Score = ", score)#prints score
break#ends code
I expect the output to be 'Correct: +3 points" when I type Fire, and to give me a second chance only when I type the incorrect answer, and then a game over once I get it wrong a second time. Instead, it repeats incorrect until the game ends no matter what I type.