Question #245632

When input is "python learning" output displayed is 16-25-20-8-15-14- 12-5-1-18-14-9-14-7 there is additional - after 14 digit. how to rectify this issue?


Expert's answer

letters = 'abcdefghijklmnopqrstuvwxyz'
print(*['-'.join([str(letters.index(ch) + 1) if ch in letters else ch for ch in word.lower()]) for word in
        input().split()])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS