"""In this kata, we're going to create the function nato that takes a word and returns a string spells the word using the NATO phonetic alphabet. There should be a space between each word in the returned string, and the first letter of each word should be capitalized. For those of you that don't want your fingers to bleed, this kata already has a dictionary typed out for you. nato("Banana") # == "Bravo Alpha November Alpha November Alph""" letters = { "A": "Alpha", "B": "Bravo", "C": "Charlie", "D": "Delta", "E": "Echo", "F": "Foxtrot", "G": "Golf", "H": "Hotel", "I": "India", "J": "Juliett","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" } def nato(word): n = len(word) x = letters[word[0].upper()] for i in xrange(1, n): x = x + " " + letters[word[i].upper()] print str(x) nato2("babble")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question