Do a more comprehensive solution, return something for every letter
voc= converts the list of nato alphabet names to a dict mapping of letter to name
def phonetic checks the input is in the dict and then returns the value, or ? if it is confused
voc=dict([[string.lower(x[0]), x] for x in
['ALFA',
'BRAVO',
'CHARLIE',
'DELTA',
'ECHO',
'FOXTROT',
'GOLF',
'HOTEL',
'INDIA',
'JULIETT',
'KILO',
'LIMA',
'MIKE',
'NOVEMBER',
'OSCAR',
'PAPA',
'QUEBEC',
'ROMEO',
'SIERRA',
'TANGO',
'UNIFORM',
'VICTOR',
'WHISKEY',
'XRAY',
'YANKEE',
'ZULU']])
def phonetic(letter):
if letter in voc:
return voc[letter]
else:
return "?"