+ 1

Is there anyone who solved "No Numerals" problem from SoloLearn's code coach with Python ?

I just solved this problem but something's goes wrong and I can't figure it out. There is 6 test case and and I passed four. Test case #4 and #5 shows wrong but I can't see them for the apps policy. Here is my code and thankyou very much for helping me... text= input().lower() text=text.split() lst=['zero','one','two', 'three','four', 'five', 'six', 'seven', 'eight', 'nine','ten'] dic={} for num,val in enumerate(lst): dic[val]=str(num) dic= {value: i for i, value in dic.items()} d=[] for word in text: if word in dic: d.append(dic[word]) else: d.append(word) join= ' '.join(d) print(join) Btw,. This is the problem link... https://www.sololearn.com/coach/64?ref=app

23rd Mar 2020, 2:11 PM
Mr Robot
Mr Robot - avatar
6 Respuestas
+ 1
https://code.sololearn.com/cPnJxYFky5cV/?ref=app This is mine, but I'll also check yours
23rd Mar 2020, 2:20 PM
Justus
Justus - avatar
+ 1
wow 😍 , your code is much more easier and perfect, thankyou bro. 💕 Can you suggest me , what's wrong with mine?
23rd Mar 2020, 2:28 PM
Mr Robot
Mr Robot - avatar
+ 1
Yours works fine, With spaces between the inputs
23rd Mar 2020, 2:40 PM
Justus
Justus - avatar
+ 1
I don't see a problem with the code, but the test cases...
23rd Mar 2020, 2:56 PM
Justus
Justus - avatar
0
Thank you bro, should I change anything ?
23rd Mar 2020, 2:51 PM
Mr Robot
Mr Robot - avatar
0
Btw, First I apply this... But there is no module called ' num2words ' in SoloLearn. But this is a awesome module, you convert any number with this. You just have change the range... from num2words import num2words text= input().lower() text=text.split() lst=[] dic={} for i in range (10): x=num2words(i) lst.append(x) for num,val in enumerate(lst): dic[val]=str(num) dic= {value: i for i, value in dic.items()} d=[] for word in text: if word in dic: d.append(dic[word]) else: d.append(word) join= ' '.join(d) print(join)
23rd Mar 2020, 2:53 PM
Mr Robot
Mr Robot - avatar