How can I make python sample different numbers every time in the while loop

Keywords: python python-3.x random


I have an idea to make an application/program to help with music theory. It would spit out random chords of a certain key, and then you have to type in which key they come from. It would be an amazing tool for me, or anyone that wants to improve their knowledge of keys.

I am really far away from my goal, but right now I have this problem I need to get through.

I figured out how to make it spit out random chords from the key, but when I put the random.sample inside the while loop, it spits out the same 4 chords out of the 8 chords in the key each time it loops.

In order to make this application, I have this plan: Out of all the keys, choose a random one, A few random chords from that key are spit out, Then you figure out which key the chords come from, and you get another question (it repeats with another random key)

I am a beginner, and thought to make this it would include the while loop, but when it loops it spits out the same few random chords, just in different order.

P.S. I haven't figured out how to make it choose a random key yet. Maybe that would solve the problem I. D. K.

I've already tried using time.sleep(3) to make the while loop wait a bit before looping. I've already tried using other things than random.sample, but they just brought up more problems like only shooting out one chords (when i used random.choice(s)).

import random

print('Key Theory Werkout')

D = {'D','E-','F⌗-','G','A','B-','C⌗dim'}
G = {'G','A-','B-','C','D','E-','F⌗dim'}
C = {'C','D-','E-','F','G','A-','Bdim'}
F = {'F','G-','A-','Bb','C','D-','Edim'}
Bb = {'Bb','C-','D-','Eb','F','G-','Adim'}
Eb = {'Eb','F-','G-','Ab','Bb','C-','Ddim'}
Ab = {'Ab','Bb-','C-','Db','Eb','F-','Gdim'}
Db = {'Db','Eb-','F-','Gb','Ab','Bb-','Cdim'}
Cx = {'C⌗','D⌗-','E⌗-','F⌗','G⌗','A⌗-','B⌗dim'}
Gb = {'Gb','Ab-','Bb-','Cb','Db','Eb-','Fdim'}
Fx = {'F⌗','G⌗-','A⌗-','B','C⌗','D⌗-','E⌗dim'}
B = {'B','C⌗-','D⌗','E','F⌗','G⌗','A⌗dim'}
Cb = {'Cb','Db-','Eb-','Fb','Gb','Ab-','B-dim'}
E = {'E','F⌗-','G⌗-','A','B','C⌗-','D⌗dim'}
A = {'A','B-','C⌗-','D','E','F⌗-','G⌗dim'}

print('Difficulty:Easy, Hard')

begin = input("Choose Difficulty:")
if begin == 'Easy':

    while begin == 'Easy':
        D= random.sample(list(D), 4)
        answer = input('Please Provide the key:')
        if answer == "D":

elif begin == 'Hard':
        D = random.sample(list(D), 3)
    print("Capitalize those letters donkey!")

This is what it spits out every time

Choose Difficulty:Easy
['E-', 'D', 'G', 'A']
Please Provide the key:D
['D', 'G', 'E-', 'A']
Please Provide the key:D
['G', 'A', 'D', 'E-']
Please Provide the key:D
['A', 'E-', 'D', 'G']

I would like it everytime to include other members of D major like             B-C⌗dim, or or F#-.

Your help is very much appreciated.