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
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)
+ 5
The Cereal Killer ,
the code you provided does create errors, as soon as thd input text contains spaces.
+ 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.
+ 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!
0
The Cereal Killer great optimization!!!