Why do i get two cases wrong in the No numerals Code coach challenge. Here's my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why do i get two cases wrong in the No numerals Code coach challenge. Here's my code

prompt= input('').lower() list= prompt.split(' ') string = " " dic = { '1':'one' , '2':'two', '3':'three', '4':'four','5':'five', '6':'six' , '7':'seven', '8':'eight', '9':'nine', '10':'ten'} for word in list: for key in dic: if word == key: index= list.index(word) list[index]= dic[key] print(string.join(list))

15th Sep 2020, 9:26 AM
Eleojo Emmanuel Adegbe
Eleojo Emmanuel Adegbe - avatar
3 Answers
+ 1
You need to change your code slightly so that it does not return "onetwo" for the number 12 or "twofive" for the number 25.
16th Sep 2020, 1:11 PM
Michael
Michael - avatar
+ 1
The code doesn't out 12 as "one two" it outputs it as "12" .. only numbers below 10 it converts. Copy the code and try it out. You'll see it works fine... I just wonder why it doesn't pass case 4&5 .. please copy and run the code you'll see. Thanks
16th Sep 2020, 8:20 PM
Eleojo Emmanuel Adegbe
Eleojo Emmanuel Adegbe - avatar
+ 1
I need to get to the bottom of this. please
16th Sep 2020, 8:22 PM
Eleojo Emmanuel Adegbe
Eleojo Emmanuel Adegbe - avatar