+ 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?
5 Respuestas
+ 1
In the second case test 3 doesn't work
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]))