I have this assignment:
Write a function
smallnr(x)that takes a number
xis an integer between
6it returns the name of the number, otherwise it simply returns
xas a string.
I did the following:
def smallnr(x): if x>6: return str(x) else: lst=['zero','one','two','three','four','five','six'] return (lst[x])
and that works, but now I have to do this:
Using the function
smallnrfrom part a, write a function
convertsmall(s)that takes as input a text
sand returns the text
swith small numbers (integers between 0 and 6) converted to their names. For example,
convertsmall('I have 5 brothers and 2 sisters, 7 siblings altogether.') 'I have five brothers and two sisters, 7 siblings altogether.'
I know I need to use
isnumeric() somehow, but I can't figure out how to put it all together and change just the numbers within the string.