So I'm having this problem in which my code is inconsistently failing at random times, this has been answered before:([Python 3.7.3 Inconsistent code for song guessing code, stops working at random times](https://stackoverflow.com/questions/57953965/python-3-7-3-inconsistent-code-for-song-guessing-code-stops-working-at-random-t/57954073#57954073)but) now I have had to add a leaderboard to this song guessing game I am doing. I randomly choose a number of which is used to find the artist and song. If right, it will remove the song and artist to prevent dupes and carry on. Here is the code:

```
loop = 10
attempts = 0
ArtCount = len(artist)
for x in range (ArtCount):
    print(ArtCount)
    randNum = int(random.randint(0, ArtCount - 1))
    randArt = artist[randNum]
    ArtInd = artist.index(randArt)# catches element position       
    songSel = songs[randNum]
    print (randNum)
    print ("The artist is " + randArt)
    time.sleep(0.5)
    songie = songSel
    print( "The songs first letter be " + songSel[0])
    time.sleep(0.5)
    print("")
    question = input("What song do you believe it to be? ")
    if question == (songSel):
        songs.remove(songSel)

        artist.remove(randArt)
        print ("Correct")
        print ("Next Question")
        if attempts ==0:
            points = points + 5
            print("+5 Points")
            print("")
     if question != (songSel):
        loop = loop + 1
        attempts = attempts + 1

        print("")
        print("Wrong,", attempts, "questions wrong, careful!")
        print("")
        time.sleep(0.5)

    if attempts == 5:
        break
        print("GAME OVER")

```

Pardon my mess, I'm just starting off in making large code, will clean up when finished. I've had the additional problem of having the count controlled loop as 10 (the amount of questions) then having to go pas the loop when you get a question wrong, I've tried having it loop by the amount of songs in the list and I've also tried making a variable that +1 when you get it wrong so you have space to answer but that doesn't work either. After implementing the leaderboard it now doesn't remove any songs (I was messing with the indentation to make the leaderboard print every time.) The error I randomly get is;

```
randArt = artist[randNum]
IndexError: list index out of range

```

I'm never sure why this is the code that is the problem, I'm not even sure if it's necessary.