py: tasks from codewars
transform
letterse
into
digits
Example
The sunset sets at twelve o' clock
Should be
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
def alphabet_position(text):
import string
s=''
text=text.lower()
for i in text:
try:
if i != ' ' and i !="'":
print (string.ascii_lowercase.index(i)+1)
s=s+str(string.ascii_lowercase.index(i)+1)+' '
else:
continue
except:
continue
return s.rstrip()#rstrip() deletes space from the end of a string
pass
Last updated
Was this helpful?