Python Forum

Full Version: Stuck on Music Quiz
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Stuck on Music Quiz Game

Hello, I am doing an assignment which is a Music Quiz Game, I have completed The Login, Menu, Rules and now need to do the game itself, but I can't figure out where to start.
I have all the songs and artists on a seperate Document, seperated by the Character "|" I have also made the code for splitting the songs and artists from each other:
def random_line(SongsArtists):
    line = next(SongsArtists.txt)
    for num, SongsArtists.txt in enumerate(SongsArtists.txt, 2):
      if random.randrange(num): continue
      line = line.strip().split("|")
    return line
I am stuck on making it pick a a random line from the artist/song list, and making it show you the artist and the song, and then you type the song as your answer. There will be another part but I will do this myself.
Any help would be appreciated. Pray
Look at random.choice(). Python docs for Random
Thanks, but what I need is a user input scenario where I have some guesses and it will go to the next question if correct (If you get what I'm saying) not a multiple choice thing, Apologies.
I don't think you went to the link and read. Random.choice is not for multiple choice.
import random

with open("SongArtists.txt","r") as file:
    lines = file.readlines()

chosen_line = random.choice(lines)
#Now split.