Mr_Fun

Charlie Quebec

Dec 3rd, 2021
624
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LASTNAME = "Funderburk"
  2.  
  3. PHONETIC = {"A": "ALPHA", "B": "BRAVO", "C": "CHARLIE", "D": "DELTA", "E": "ECHO", "F": "FOXTROT",
  4.             "G": "GOLF", "H": "HOTEL", "I": "INDIA", "J": "JULIET", "K": "KILO", "L": "LIMA",
  5.             "M": "MIKE", "N": "NOVEMBER", "O": "OSCAR", "P": "PAPA", "Q": "QUEBEC", "R": "ROMEO",
  6.             "S": "SIERRA", "T": "TANGO", "U": "UNIFORM", "V": "VICTOR", "W": "WHISKEY", "X": "XRAY",
  7.             "Y": "YANKEE", "Z": "ZULU"}
  8.  
  9.  
  10. def phonetic(msg):
  11.     encoded = ""
  12.     # ensure the message in in all caps
  13.     msg = msg.upper()
  14.  
  15.     # loop through each letter in the message
  16.     for letter in msg:
  17.         # if there's a space, remove the hyphen to the previous word, add it, and skip the remaining logic
  18.         if letter == " ":
  19.             encoded = encoded[0:len(encoded)-1]
  20.             encoded += " "
  21.             continue
  22.  
  23.         encoded += PHONETIC[letter] + "-"
  24.  
  25.     # remove the final hyphen and return
  26.     return encoded[0:len(encoded)-1]
  27.  
  28.  
  29. # print(phonetic("this challenge was too easy"))
RAW Paste Data