I've got a variable, and it's being used in the condition of a while loop inside a function. I get an error upon running that function saying: local variable 'audioLength' referenced before assignment
song = input("Enter a song to play: ")
songFile = song + ".mp3"
mp3File = MP3(songFile)
audioLength = int(mp3File.info.length)
def play():
pygame.mixer.music.load(song + ".mp3")
pygame.mixer.music.play()
while audioLength != 0:
audioLength -= 1
time.sleep(1)
I'm not sure why it thinks audioLength
is a local variable, and how can I fix this?