+ 1
Can any one tell me that how can I pass test case#3 in No numerals challenge and what's wrong in the code below
Using Python https://code.sololearn.com/cmkK7WhEvCeW/?ref=app
3 odpowiedzi
+ 1
10 should be early then 1 and 0
+ 1
0
First of all 10 is replaced by onezero and secondly numbers greater than 10 should not be replaced, should they?
Moreover all this replaces look ugly!
Try this instead:
inp = input()
num = ["10","0","1","2","3","4","5","6","7","8","9","10"]
alp = ["zero","one","two","three","four","five","six","seven","eight","nine","ten"]
for n in num:
if n in inp:
inp = inp.replace(n,alp[int(n)])
print(inp)