simple python music quiz I'm currently learning python and created a simple music quiz. the rules of the game are as follows:

The user has two chances to guess the name of the song If the user guesses the answer correctly the first time, they score 3 points. If the user guesses the answer correctly the second time they score 1 point.The game repeats.The game ends when a player guesses the song name incorrectly the second time.

I developed the following but the I wasn't very pleased with the update leaderboard function as the indexing of the 2d list was confusing to code. is there an easier way to do the same thing? 

start_quiz returns two variables and is there a way to sort of 'unpack' what's returned?   

# 21:23 5th dec 2019
from Resources.songs import songs
from Resources.users import users
import random
import pickle


def main():
    username = login()
    print('hello', username, 'welcome to the music quiz')
    guessed_wrong_twice = False
    result = None
    while not guessed_wrong_twice:
        result = start_quiz()
        guessed_wrong_twice = result[1]
    score = result[0]
    print('you scored', score)
    leaderboard = leaderboard_updating(username, int(result[0]))
    print('The leaderboard:\n', leaderboard)


main()



def login():
    logged_in = False
    entered_username = None
    while not logged_in:
        entered_username = input("please enter username: ")
        if entered_username in users:
            entered_password = input('please enter password: ')
            if entered_password == users[entered_username]:
                logged_in = True
        else:
            print("password or username incorrect try again")
            logged_in = False

    return entered_username



def start_quiz():
    score = 0
    guessed_wrong_twice = False
    song_chosen = choosing_song()
    print('artists name is', song_chosen[1])
    first_letter = song_chosen[0][0]
    guess = input("the song begins with" + first_letter)
    if guess.lower == song_chosen[0]:
        score += 3
    else:
        guess = input("the song begins with " + first_letter)
        if guess.lower == song_chosen[0]:
            score += 1
        elif guess != song_chosen[0]:
            guessed_wrong_twice = True
    return score, guessed_wrong_twice


def choosing_song():
    song_chooser = random.randint(1, 3)
    song_artist = songs[song_chooser][1]
    song_name = songs[song_chooser][0]
    return song_name, song_artist

# index 0 of each 'sub list' is the users name index 1 is their highest score

def leaderboard_updating(username, score=0):

    leaderboard = pickle.load(open("leaderboard.pickle", "rb"))

    index_row_list = [leaderboard.index(row) for row in leaderboard if username in row]
    index_row = int(index_row_list[0])
    if leaderboard[index_row][1] &lt; score:
        leaderboard[index_row][1] = score

    leaderboard = sorted(leaderboard, key=lambda x: x[1])

    pickle.dump(leaderboard, open("leaderboard.pickle", "wb"))
    return leaderboard
Note: Not an answer, an extended comment.

There's no way your code can work the way you intend it to.


Your leader board doesn't work when the user isn't already in the leader board.

The second line will IndexError in these cases:


index_row_list = [leaderboard.index(row) for row in leaderboard if username in row]
index_row = int(index_row_list[0])


You can never score more than 3 points on the leader board.


while not guessed_wrong_twice:
    result = start_quiz()
    guessed_wrong_twice = result[1]
score = result[0]


You can never enter a correct song.


if guess.lower == song_chosen[0]:



Looks innocent enough, but it's never true. Unless song_chosen[0] is str.lower. In which case it's always true.

&gt;&gt;&gt; 'abc'.lower == 'abc'
False



Now 1 &amp; 2 are pretty minor, so if your code only contained them I'd just answer. But 3 means it's impossible for your code to work.

Given that start_quiz was the last function I reviewed I have a half written review for you. Please fix the above problems for it.