[Solved] No Numerals
I tried to solve this question: Task: Take a phrase and replace any instances of an integer from 0-10 and replace it with the English word that corresponds to that integer. Sample Input: i need 2 pumpkins and 3 apples Sample Output: i need two pumpkins and three apples This is my code: original_text = input().lower() arr = ["zero","one","two","three","four","five","six","seven","eight","nine","ten"] lst = original_text.split(" ") for i in lst: try: if i.isdigit() & int(i) <= 10: original_text = original_text.replace(i,arr[int(i)]) except: pass print(original_text) It worked for test cases 1,2,3 and 6 But it failed in test cases 4 and 5. I don't know what is the problem and if I could write a better code. Thank you for your help.