# push the five songs into the stack stack = [] stack.append((1, "One call away")) stack.append((2, "Firework")) stack.append((3, "Faded")) stack.append((4, "I believe I can fly")) stack.append((5, "Just the way you are")) # generate and display random numbers from random import randint # save the random played song played = [] while True: x = randint(1, 10) print ("Random Number:") print (x) if 1 <= x <= 8: if len(played) < 5: # play a random song from the stack # only if the number of played songs is no more than 5 song = stack.pop() played.append(song) else: # push exit onto a stack to break the loop break print ('\nHave a nice day') # display the played songs if len(played) > 0: print ('\nWe have played the following song(s):') for song in played: print ("#%d - %s" % (song[0], song[1]))