Write a function that takes an integer as input argument and returns the integer using words. For example if the input is 4721 then the function should retur
def number_to_words(number):
names = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
lst = []
while True:
lst.insert(0, number % 10) # Prepend
number /= 10
if number == 0: # Do this here rather than in the while condition
break; # so that 0 results in ["zero"]
# If you want a list, then:
return lst;
# If you want a string, then:
return " ".join(lst)