Say I have the following string:
string1 = 'Twenty 20 Twelve 12'
I would like to convert it into a list that would keep words as strings in separate elements, and numbers in another (as integers):
list1 = ['Twenty', 20, 'Twelve', 12]
My current code looks is:
list1 = [y for y in string1.replace(' ','')]
and the result prints out as:
['T','w','e','n','t','y','2','0','T','w','e','l','v','e','1','2']
How would I be able to write a code to keep words in separate entries, and turn numbers inside the string into integers in the list? I am a beginner to programming who is currently learning Python in parallel with C.