+ 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?

12th Jan 2020, 6:33 PM
Ярослав Радченко
Ярослав Радченко - avatar
5 Respuestas
+ 1
In the second case test 3 doesn't work
12th Jan 2020, 6:49 PM
Ярослав Радченко
Ярослав Радченко - avatar
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=" ")
17th Aug 2020, 1:15 PM
venkata santhosh
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]))
3rd Mar 2021, 3:36 AM
tom
tom - avatar