Jul-03-2020, 01:56 PM
Hello
I am currently coding a music quiz game. Here is my current code.
With how the code is currently, if the user guessed the song the first try it works and puts another song guess on. However, if the user gets the first guess wrong, the code goes to the 'else' bit at the bottom of the code i pasted in, if they get the code right on this last attempt instead of giving them a nice guess like the code should do, it just ends the code.
Any help would be great.
I am currently coding a music quiz game. Here is my current code.
pop00_tries_left = 2 score = 0 while pop00_tries_left > 0: with open("2000POPSONGLIST.txt", "r") as pop00songs_file: with open("2000POPARTISTLIST.txt", "r") as pop00artists_file: pop00songs_and_artists = [(pop00song.rstrip('\n'), pop00artist.rstrip('\n')) for (pop00song, pop00artist) in zip(pop00songs_file, pop00artists_file)] random00pop_song, random00pop_artist = random.choice(pop00songs_and_artists) pop00songs_intials = "".join(item[0].upper() for item in random00pop_song.split()) print("The songs' initials are", pop00songs_intials, "and the name of the artist is", random00pop_artist) pop00guess = input("Guess the name of the song! ") pop00_tries_left = pop00_tries_left - 1 if pop00guess == random00pop_song: print("Well Done!") score = score + 1 time.sleep(0.5) print("Your Score Is", score) pop00_tries_left = 2 else: pop00guess = input("Nope! Try Again! Guess the name of the song again! ") pop00_tries_left = pop00_tries_left - 1If the person guesses correctly on their second guess (which is the else part) how do i get the loop to go back to the start?
With how the code is currently, if the user guessed the song the first try it works and puts another song guess on. However, if the user gets the first guess wrong, the code goes to the 'else' bit at the bottom of the code i pasted in, if they get the code right on this last attempt instead of giving them a nice guess like the code should do, it just ends the code.
Any help would be great.