Write parts 1 (convert string to lowercase) and 2 (tokenize string) of that code and incorporate the function below. Use the string.split function. Get the code to work as a cohesive unit to convert strings like "two hundred sixty two" to numbers like 262.
This is basically what I need to do.
def turn_words_into_numbers(number_list): output = 0 current = 0 for index in range(len(number_list)): current = eval(number_list[index]) if(output==0): output=output+current elif(output < current): output=output*current elif(output>current): output=output+current else: return('error') print('index:',index,'output:',output,'current:',current) return(output)
The code is not really correct, so any help would be greatly appreciated, I have NO idea what to do.