+ 1

Please help! passed all tests but one keeps failing. A program to replace all occurrences of numbers with equivalent spellings

Sololearn Coding Challenges

1st Apr 2021, 9:14 PM
DOJ
DOJ - avatar
3 ответов
+ 2
a=input().split() dic={"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 range(len(a)):     if a[i] in dic:         a[i]=dic[a[i]] print(' '.join(a))
1st Apr 2021, 9:30 PM
Qasem
+ 3
Thanks.. way simpler than wat i was trying :))
1st Apr 2021, 9:57 PM
DOJ
DOJ - avatar
+ 2
https://www.sololearn.com/coach/64?ref=app And this is my code: numbers = { '0':'zero', '1':'one', '2':'two', '3':'three', '4':'four', '5':'five', '6':'six', '7':'seven', '8':'eight', '9':'nine', '10':'ten' } def phrase(question): question.lower() for key in numbers: if len(key) == 1 and key in question or key == '10': question = question.replace('{}'.format(key), '{}'.format(numbers.get('{}'.format(key)))) return question test = input() print(phrase(test))
1st Apr 2021, 9:14 PM
DOJ
DOJ - avatar