So, step 18 of the Thread Shed exercise - Strings Chapter asks for:
Next, iterate through thread_sold. For each item, check if it is a single color or multiple colors. If it is a single color, append that color to
thread_sold_split. If it is multiple colors, first split the string around the
&character and then add each color individually to
However, the video walkthrough solution does not solve it that way. The dev says it is not necessary to check, since .split("&") will only act on the items that have the “&” anyway. So he solved it like this:
thread_sold_split =  for sale in thread_sold: for color in sale.split("&"): thread_sold_split.append(color)
I did try to check using the code below, though, but it did not work. I expected to append the collors individually but it keeps appending the lists of colors that were generated on the split.
thread_sold_split =  for item in thread_sold: if "&" in item: splitted_item =  splitted_item.append(item.split("&")) for singlecolor in splitted_item: thread_sold_split.append(singlecolor) else: thread_sold_split.append(item)
I would like to know why this code is not working, since I can’t check the solution to find out because the solution went through a different path.