0

Please I don't know why this code doesn't execute correctly for all the possibilities

phrase = input() if "0" in phrase and "1" not in phrase: phrase = phrase.replace("0","zero") if "1" in phrase and "0" not in phrase: phrase = phrase.replace("1","one") if "2" in phrase: phrase = phrase.replace("2","two") if "3" in phrase: phrase = phrase.replace("3","three") if "4" in phrase: phrase = phrase.replace("4","four") if "5" in phrase: phrase = phrase.replace("5","five") if "6" in phrase: phrase = phrase.replace("6","six") if "7" in phrase: phrase = phrase.replace("7","seven") if "8" in phrase: phrase = phrase.replace("8","eight") if "9" in phrase: phrase = phrase.replace("9","nine") if "1" in phrase and "0" in phrase: phrase = phrase.replace("10","zero") print(phrase)

28th Feb 2021, 1:31 PM
kum brian
kum brian - avatar
2 odpowiedzi
+ 2
Input -> 10 Output -> zero ❌ Expected output -> ten ✅
28th Feb 2021, 1:33 PM
Arsenic
Arsenic - avatar
0
thank u. I found the error
28th Feb 2021, 1:36 PM
kum brian
kum brian - avatar