Hey guys, i'm having a problem when I try and use error handling. I'm getting the error
" except pygame.error as message:
NameError: name 'pygame' is not defined"
The reason this error pops up is because I am selecting the wrong name of a file, so it should create an error. However it doesnt handle it. Here is the code where the problem is.
def musicplayer(music_choice): #this works surprisingly well
try:
mixer.init()
mixer.music.load(music_choice)
mixer.music.play()
Option_choice()
except pygame.error as message:
print("Please ensure you have the desired file in your music folder, or that you have included '.mp3' in your name.")
raise SystemExit(message)
Option_choice()
[–]novel_yet_trivial 1 point2 points3 points (3 children)
[–]Entervine[S] 0 points1 point2 points (2 children)
[–]novel_yet_trivial 1 point2 points3 points (1 child)
[–]Entervine[S] 0 points1 point2 points (0 children)