0

No numerial

Hi guys, I have tried this task and am able to get 3 test cases right. Can anybody please fix this https://code.sololearn.com/ckvQatPIoR6f/?ref=app

20th Apr 2023, 5:28 AM
Ayush Ghara
Ayush Ghara - avatar
7 Answers
+ 5
Ugulberto SĂĄnchez , the code you provided can not pass the test cases, since there are some issues: phrase = list(input()) # => creates a list of *individual characters*. this is not correct # => input has to be splitted to *individual words* for x in range(len(phrase)): if phrase[x]=="1": phrase[x] = "one" elif phrase[x]== "2": ... else: # => else clause is not required here continue # ... result = "".join(phrase) # => to get the new string by using join(), we need to use a space as separator print(result)
20th Apr 2023, 5:25 PM
Lothar
Lothar - avatar
+ 5
The Cereal Killer , the code you provided does create errors, as soon as thd input text contains spaces.
20th Apr 2023, 5:29 PM
Lothar
Lothar - avatar
+ 2
https://code.sololearn.com/cHUWcrKI4hZw/?ref=app I fixed it. You were using replace with every single character, so the code didn’t work. Use range loops instead and it will work Note: the input must be a list for the code I made, and to print it you must join the list into a string.
20th Apr 2023, 6:37 AM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 2
Lothar ahhhh i didn’t understand the problem, so I rewrote the code that ayush pushed and deleted the errors. Thanks for your feedback!
20th Apr 2023, 5:27 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
0
The Cereal Killer great optimization!!!
20th Apr 2023, 9:48 AM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar