Task no numerals | Sololearn: Learn to code for FREE!

+1

Task no numerals

words = input('') chars = ' abcdefghijklmnopqrstuvwxyz' numbers = {'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine','10':'ten'} for i in words: if i not in chars: k = str(i) words = words.replace(i,numbers[k]) print(words) words = input('') numb = '1234567890' numbers = {'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine'} for i in words: if i in numb: k = str(i) words = words.replace(i,numbers[k]) print(words) None of them doesn't work at well, why?

1/12/2020 6:33:38 PM

Ярослав Радченко

5 Answers

New Answer

+3

https://www.sololearn.com/discuss/2114051/?ref=app https://www.sololearn.com/discuss/2132249/?ref=app https://www.sololearn.com/discuss/2123963/?ref=app https://www.sololearn.com/discuss/2103324/?ref=app https://www.sololearn.com/discuss/2122495/?ref=app

+1

In the second case test 3 doesn't work

0

Indentation error

0

n=list(map(str,input().split(" "))) m=("zero","one","two","three","four","five","six","seven","eight","nine","ten") N=("0","1","2","3","4","5","6","7","8","9","10") for i in n: if i in N: q=n.index(i) p=N.index(i) n[q]=m[p] for j in n: print(j,end=" ")

0

sent = (input()) dict = {"1": "one", "2": "two", "3": "three", "4": "four", "5": "five", "6": "six", "7": "seven", "8": "eight", "9":"nine", "10": "ten"} sentlst = sent.split(" ") print(" ".join([dict.get(n, n) for n in sentlst]))