Nov-11-2018, 11:31 PM
Actually, instead of tuples, you can use your dictionary. I'd replace your loop like so (untested)
# this only need to be defined once (not in the loop); I use sounds.keys() instead of a separate tuple sounds = {"A7": A7, "Amaj": Amaj, "Amin": Amin, "Amin7": Amin7, "Cmaj": Cmaj, "D7": D7, "Dmaj": Dmaj, "E7": E7, "Emaj": Emaj, "Emin": Emin, "Emin7": Emin7, "Gmaj": Gmaj} while True: choice = random.choice(sounds.keys()) winsound.PlaySound(choice, winsound.SND_FILENAME|winsound.SND_ASYNC) print("A7, Amaj, Amin, Amin7, Cmaj, D7, Dmaj, E7, Emaj, Emin, Emin7, Gmaj") guess = input("What sound was just played?: ") if sounds.get(guess) == choice: print("Well done!") else: print("Try again.")The alternative with tuples is a list of pairs instead of a dictionary. You'd use random.choice() on the list, and get a pair containing the sound path and the expected guess string. You could then use that. I think a list of tuples is slightly simpler, but it's up to you what you want to stick to.