How do I return my list so that the list is composed of strings rather than lists?
Here is my attempt:
def recipe(listofingredients):
listofingredients = listofingredients
newlist = []
newlist2 = []
for i in listofingredients:
listofingredients = i.strip("\n")
newlist.append(listofingredients)
for i in newlist:
newlist = i.split()
newlist2.append(newlist)
return newlist2
result = recipe(['12345\n','eggs 4\n','$0.50\n','flour 5\n','$2.00\n'])
print result
And my output is this:
[['12345'], ['eggs', '4'], ['$0.50'], ['flour', '5'], ['$2.00']]
Desired output:
['12345', 'eggs', '4', '$0.50', 'flour', '5', '$2.00']
I know that my issue here is appending one list to another, but I'm not sure how to use .strip() and .split() on anything other than a list.