Let’s walk through a function strategy and then you can convert it into code.
First of all,
results = '' is not a string, but rather a list. Therefore, initialize it to be an empty list:
results = . That’s where you will store the results as you loop through the numbers.
Does that make sense? If no, let’s talk about it.
Let’s think about the dataset you are getting within this function. It’s a list of lists.
n has 2 lists inside of it. Right?
The first loop
for number in lists: is looping through the items in the
Loop 1 ->
[1, 2, 3].
Loop 2 ->
[4, 5, 6, 7, 8, 9]
Notice that you get another list with the loop. Right?
Think about how you can loop through those inner lists to append each number into your
results list. Give that a try.