From cc36c9613426507cb2b7e726e9c2d217bf862e2e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 11 May 2017 21:29:51 +0200 Subject: Add phone speller script --- nato.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 nato.py diff --git a/nato.py b/nato.py new file mode 100755 index 0000000..a8788e0 --- /dev/null +++ b/nato.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +nato = [ + 'Alfa', + 'Bravo', + 'Charlie', + 'Delta', + 'Echo', + 'Foxtrot', + 'Golf', + 'Hotel', + 'India', + 'Juliet', + 'Kilo', + 'Lima', + 'Mike', + 'November', + 'Oscar', + 'Papa', + 'Quebec', + 'Romeo', + 'Sierra', + 'Tango', + 'Uniform', + 'Victor', + 'Whiskey', + 'X-ray', + 'Yankee', + 'Zulu', +] + +alphabet = { w[0]: w for w in nato } + +def str_to_telephony(phrase): + return [ alphabet[c] if c in alphabet else c for c in phrase.upper() ] + + +import sys + +print('\n'.join(str_to_telephony(" ".join(sys.argv[1:])))) -- cgit v1.2.3