I have a very simple code to randomly choose a key (musical key) from a list. How do i store that value so from that point on the program knows the selected key.
import random
majorkeys = ['A major', 'Bb major', 'B major', 'C major', 'Db major', 'D major', 'Eb major', 'E major', 'F major',
'Gb major', 'G major', 'Ab major']
minorkeys = ['A minor', 'Bb minor', 'B minor', 'C minor', 'Db minor', 'D minor', 'Eb minor', 'E minor', 'F minor',
'Gb minor', 'G minor', 'Ab minor']
allkeys = majorkeys + minorkeys
#Lydia - in reference to Lydian Mode.
print("""
Hey there, my name is Lydia,
I'm here to help you start a song!
""")
knownkey = (input("Do you know what key you would like to start with? "))
if knownkey == "no":
print("\nLet me help you get this song off the ground! Try start with:")
print(random.choice(allkeys))
else:
print("That's a great starting point! Nice Work!")
confirmkey = (input("Are you happy to continue with this key? "))
while confirmkey == 'no':
print("No worries! Lets do:")
print(random.choice(allkeys)+" instead!")
confirmkey = (input("Are you happy to continue with this key? "))
if confirmkey == "yes":
print("Great!")
Aucun commentaire:
Enregistrer un commentaire