Thread Shed

I seem to be getting an Index error, and I can’t see why.

The Error = Traceback (most recent call last):
File “”, line 137, in
IndexError: list index out of range

The code =

daily_sales_replaced = daily_sales.replace(";';", "+")


daily_transactions = daily_sales_replaced.split(",")

# print(daily_transactions)

daily_transactions_split = []

for transaction in daily_transactions:


# print(daily_transactions_split)

transactions_clean = []

for transaction in daily_transactions_split:

  transaction_clean = []

  for data_point in transaction:


    transaction_clean.append(data_point.replace("\n", "").strip(" "))



customers = []

sales = []

thread_sold = []

for transaction in transactions_clean:







total_sales = 0

for sale in sales:

  total_sales += float(sale.strip("$"))


Hi @platosguts. Any chance you could resubmit your code but fully formatted. You can find the details on this at the following link-

Regarding your issue I’d make sure you double check your indentation.

1 Like

I have corrected the code formatting. :slight_smile:

Hello, @platosguts, and welcome to the forums!

While working on the code for a large set of data, which in this case is a really long string, it helps to take a small piece of the data, and work with it until you have all of the bugs worked out. It also helps to test each piece of new code as you go. If you comment out everything but the first line of code that you shared, and add print(daily_sales_replaced) you’ll notice a problem. If the first line of code isn’t working the way you expected, everything from there on is going to be off.

1 Like

Thanks everyone! I had indentation problems.

1 Like