Created
October 22, 2017 09:06
-
-
Save bondnotanymore/e0f1dcaacfb782348e74fac8b224769e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alphabet_position(text_string): | |
dict1 = {value: (int(key) + 1) for key, value in enumerate(list(string.ascii_lowercase))} | |
return " ".join([str(dict1[alp]) for alp in list(text_string.lower()) if alp.isalpha()]) | |
print alphabet_position("The sunset sets at twelve o' clock.") | |
Output : | |
"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you come up with the following error:
The way to get around it is to import string.
And it should work.