Как сделать так, чтобы этот код дал мне две попытки угадать песню и вывести «Game Over», когда я выполнил две попытки? - PullRequest
0 голосов
/ 28 января 2020

Эта программа работает по большей части, однако мне нужно, чтобы она выводила «Game Over», когда я добиваюсь двух попыток, и мне нужна она, чтобы позволить мне попытаться угадать одну и ту же песню дважды, прежде чем перейти к другой случайно сгенерированной песне.

def Game():

import random
score = 0

Songs_dict = {
    'First letters of each word of the song are B  Y  A  D': 'T Pain',
    'First letter of the song is R': 'Eminem ft Ed Sheeran',
    'First letter of the song is S': 'Post Malone ft Swae Lee',
    'First letters of the song are T  O  L': 'Ed Sheeran',
    'First letter of the song is L': 'Juice WRLD',
    'The first letter of the song is S': 'XXXTentacion',
    'The first letter of the song is R': 'Arizona Zervas',
    'First letters of the song are N  G': 'Chris Brown ft Drake',
    'First letter of the song is V': 'Eminem',
    'First letter of the song is U': 'French Montana ft Swae Lee',
    'The first letter of the song is L': 'Khalid',
    'The first letters of the song are T  M  B  T  L': 'Stormzy ft Ed Sheeran,Aitch and Jaykae',


}

for x in range(1,100):

        print('Question number',x)
        rgensong = random.choice(list(Songs_dict))
        print(rgensong,'-', Songs_dict[rgensong])
        attempts = 0



        song_guess = input('What do you think the song is?')
################################################## ############### Очки набраны без попыток
        while rgensong == 'First letters of each word of the song are B  Y  A  D':
            if song_guess == 'Buy You A Drank' and attempts == 0:
                print('Correct')
                score += 3
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break




        while rgensong == 'First letter of the song is R' and attempts == 0:
             if song_guess == 'River' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'River' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'River' and attempts == 1:
                break


        while rgensong == 'First letter of the song is S' and attempts == 0:
             if song_guess == 'Sunflower' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Sunflower' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Sunflower' and attempts == 1:
                break


        while rgensong == 'First letters of the song are T  O  L' and attempts == 0:
             if song_guess == 'Thinking Out Loud' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Thinking Out Loud' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Thinking Out Loud' and attempts == 1:
                break




        while rgensong == 'The first letter of the song is S' and attempts == 0:
             if song_guess == 'SAD' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'SAD' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'SAD' and attempts == 1:
                break



        while rgensong == 'First letter of the song is L' and attempts == 0:
             if song_guess == 'Legends' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Legends' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Legends' and attempts == 1:
                break





        while rgensong == 'The first letter of the song is R' and attempts == 0:
             if song_guess == 'Roxanne' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Roxanne' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Roxanne' and attempts == 1:
                break





        while rgensong == 'First letters of the song are N  G' and attempts == 0:
             if song_guess == 'No Guidance' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'No Guidance' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'No Guidance' and attempts == 1:
                break


        while rgensong == 'First letter of the song is V' and attempts == 0:
             if song_guess == 'Venom' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Venom' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Venom' and attempts == 1:
                break




        while rgensong == 'First letter of the song is U' and attempts == 0:
             if song_guess == 'Unforgettable' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Unforgettable' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Unforgettable' and attempts == 1:
                break



        while rgensong == 'The first letter of the song is L' and attempts == 0:
             if song_guess == 'Location' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Location' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Location' and attempts == 1:
                break



        while rgensong == 'The first letters of the song are T  M  B  T  L' and attempts == 0:
             if song_guess == 'Take Me Back To London' and attempts == 0:
                print('Correct')
                score += 3
                break

             elif song_guess != 'Take Me Back To London' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Take Me Back To London' and attempts == 1:
                break
########################### ########################## очков, набранных при последней попытке
        while rgensong == 'First letters of each word of the song are B  Y  A  D' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break




        while rgensong == 'First letter of the song is R' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break



        while rgensong == 'First letter of the song is S' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break




        while rgensong == 'First letters of the song are T  O  L' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break





        while rgensong == 'The first letter of the song is S' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break



        while rgensong == 'First letter of the song is L' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break





        while rgensong == 'The first letter of the song is R' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break






        while rgensong == 'First letters of the song are N  G' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break


        while rgensong == 'First letter of the song is V' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break




        while rgensong == 'First letter of the song is U' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break



        while rgensong == 'The first letter of the song is L' and attempts == 1:
            if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

            elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

            elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break



        while rgensong == 'The first letters of the song are T  M  B  T  L' and attempts == 1:
             if song_guess == 'Buy You A Drank' and attempts == 1:
                print('Correct')
                score += 1
                break

             elif song_guess != 'Buy You A Drank' and attempts == 0:
                print('Incorrect')
                attempts += 1

             elif  song_guess != 'Buy You A Drank' and attempts == 1:
                break





        print('Your score is',score)

        while attempts == 2:
            print('Game Over\n\n\nYou scored',score,'points')
...