Learn Python 3 - Thread Shed

Hi All,

I’m back again with another issue, I have a bit of code on Question 10 for Thread Shed, I realised an error within a previous command and fixed that, I then realised I have duplicates of the original string now. I went back through printing and have found the duplicates are added after this block of code is ran, but I can’t really figure out why…

daily_sales_replaced = daily_sales.replace(";,;", ";;;") #print(daily_sales_replaced) daily_transactions = daily_sales_replaced.split(",") #print(daily_transactions) daily_transactions_split = [] for string in daily_transactions: daily_transactions_split.append(string.split(";;;")) #print(daily_transactions_split) transactions_clean = [] for transaction in daily_transactions_split: transaction_clean = [] for data_point in transaction: transaction_clean.append(data_point.strip()) transactions_clean.append(transaction_clean) #print(transactions_clean)

I followed the video guide on get unstuck to see if I could see what’s happened and they essentially done the same thing. (I’ve now copied that particular block for what I think is word for word) but still seeing issues - I’m guessing the issue is somewhere in the for loop but my beginner brain can’t quite make sense of exactly where it’s going wrong!

Thanks for any help in advance.

So you’ve narrowed it down to a single code block, good job. Can you go a bit further? This kind of debugging is a worthwhile skill to practise. For a hint consider how many times it repeats and your usage of code which is designed to repeat.

If you still can’t get it after digging a little deeper then a search of the forums should find you numerous questions/answer from users who’ve hit the same stumbling block.

2 Likes

Thank you, I forgot to update this yesterday. I can’t believe that after almost a day spent stuck on figuring out why it was doing what it was, the answer was so simple.

We live and learn! Thanks again :slight_smile:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.