This is a little program I put together to help people learn the phonetic alphabet. Feel free to query the code.
import random
phonetic = { 'a' : 'alpha', 'b' : 'bravo', 'c' : 'charlie', 'd' : 'delta', 'e' : 'echo', 'f' : 'foxtrot', 'g' : 'golf', 'h' : 'hotel', 'i' : 'india', 'j' : 'juilett', 'k' : 'kilo', 'l' : 'lima', 'm' : 'mike', 'n' : 'november', 'o' : 'oscar', 'p' : 'papa', 'q' : 'quebec', 'r' : 'romeo', 's' : 'sierra', 't' : 'tango', 'u' : 'uniform', 'v' : 'victor', 'w' : 'whiskey', 'x' : 'x-ray', 'y' : 'yankee', 'z' : 'zulu' }
print('Welcome to the IkeaFish Phonetic Trainer. \n Answer no or n to stop the program.')
again = 'yes'
while again != 'no' or 'n':
#Picks either 0 or 1. If equal to 1 tests the letters, If equal to 0, tests the words.
if random.randint(0,1) == 1:
question = random.choice(list(phonetic.keys()))
answer = input('What does this letter {} stand for: '.format(question))
if answer == phonetic[question]:
print('Correct')
else:
print('Wrong answer', question, 'stands for', phonetic[question])
else:
letter = random.choice(list(phonetic.keys()))
#Grabbing a random key
question = phonetic[letter]
answer = input('What does this word {} stand for: '.format(question))
if answer == letter:
print('Correct')
else:
print('Wrong answer', question, 'stands for', phonetic[letter])