Trying to create a guessing game.
I've got a CSV file with 2 columns. The first contains artist names, the second contains song titles
I want to be able to display a random artist name and then the first letter of each word in the song title e.g.
Led Zeppelin - S******* t* H*****
So far I've been able to get it to select a random artist from the file and display both the artist and song title
import random
import time
filesize = 11251
offset = random.randrange(filesize)
words = []
print("Welcome to the music guessing game")
def randomsong():
file = open("musicFile.csv","r")
file.seek(offset)
file.readline()
line =file.readline()
data = line.split(",")
print (data[0], data[1])
song = data[1]
song = str(song)
print(song)
guesses = 2
Score = 0
song = song.lower()
while guesses != 0:
yourguess = input ("Guess the name of the song")
if yourguess == song:
print ("Well Done!")
else:
print ("Incorrect, try again ")
guesses = guesses -1
print("Game Over!!!")
randomsong()
Users should then be able to try and guess the song.
I know the code above is printing the artist and song title and the song title again, I'm just testing it to make sure it's selecting what I want.
Separate issue: the IF statement is always saying "incorrect please try again" even if I put in the correct answer.
I'm not just looking for someone to do this for me; if you could explain where I've gone wrong I'd appreciate it.