Stuck on project Thread shed - Python

I need help on step 18 it doesn’t seem to work I’m getting lists inside my list with more than one color in them
https://www.codecademy.com/paths/computer-science/tracks/cspath-python-objects/modules/cspath-python-strings/projects/thread-shed

Then perhaps you might want to iterate through each thing in your list and for each such value consider whether it needs to be broken apart, and to put all the results of that into a list.
Programming is about moving information around and reshaping it, isn’t? So a bit of that would solve this. Perhaps there wasn’t a direct instruction from codecademy on how to do it, but if you look at what you currently have and what you need to have then you can start figuring out what actions would bridge that difference.

you mean to iterate twice, once to get rid of the ‘&’ signs and add to a list and once to split it and make the new list?

If you get rid of & then wouldn’t you lose track of where to split?

Doesn’t really matter. Pick a strategy, ask yourself if you’re convinced it’ll get you closer to what you want, implement it, check the results, anything else to do? Do it/don’t. Next thing.

I’ll try that thanks!
:+1:

If they’re still strings then you may want to split them regardless of whether there’s an ampersand in them, that saves you from having two paths for two different cases, they’re really the same case and a single path will deal with both scenarios just fine.

can you please look at the program link above and see the problem cause I don’t seem to understand what you mean

What I’m saying is that

"a"
and
"a&b"

can both be split on &, even the one that doesn’t have & in it.

No I can’t look at any code, you haven’t provided any. But I probably don’t need to look at anything either, it’s more about adjusting what you have and you don’t need me for that.

I’ve tried that already.
it seems to split the strings in to lists, so I get a list of lists with separate strings. some of the lists have more than one string in them because they were the ones I was trying to split with the .spit(’&’) and they didn’t get split twice.
how do I split the list in a way that will give me a list of strings?
I’m appending index [2] of every transaction to the list I’m trying to split

thread_sold.append(transaction[2].split('&'))

in this case I do need the basic technical help if you need any code let me know and I’ll paste it

If splitting gives you a list of colors, then you’d keep each color in the list

or keep each list for now, and then later on in a separate step turn that into a single list

having this:

[['orange'], [], ['blue', 'purple', 'cyan']]

Is not a bad thing. Ask yourself what operations you’d need to carry out to turn that into:

['orange', 'blue', 'purple', 'cyan']

It’s still a step in the right direction there’s no reason why you have to avoid intermediate representations

I know you prefer not to give exact technical advice as I saw you posted in some forum, but I’ve been stuck on this project for a very long time, and I really just want to finish it. and as I’m studding coding as a hobby and not as a plan for a carrier :wink: it is really no problem if I don’t get it myself.
I’d really like it if you can just give me a solution.
thanks! :+1:

BTW:
is there a join method? and if so can I use it for this problem?

1 Like