Thread-Shed

Good morning. So I am doing Thread-Shed project on this page: https://www.codecademy.com/courses/learn-python-3/projects/thread-shed
When I start getting this error. It doesn’t make any sense as I know what it means but it should not be appearing at all.
Any advice would be appreciated. Thank you. :grin:

File "script.py", line 121
    transaction_clean.append(data_point.strip(" "))         
transactions_clean.append(transaction_clean)
    ^
IndentationError: expected an indented block

Now here is my code:

daily_sales_replaced = daily_sales.replace(";,;", "+")
daily_transactions = daily_sales_replaced.split(",")

daily_transactions_split = []
for transaction in daily_transactions:
  daily_transactions_split.append(transaction.split("+"))

transactions_clean = []
for transaction in daily_transactions_split:
  transaction_clean = []
  for data_point in transactions:
transaction_clean.append(data_point.strip(" "))         
transactions_clean.append(transaction_clean)

print(transactions_clean)

Hello!

It looks like you want these two lines of code to run inside of the for data_point in transactions loop, so you would want to indent them both by two spaces like you’ve done with the other two loops in the code: :slight_smile:

transaction_clean.append(data_point.strip(" "))         
transactions_clean.append(transaction_clean)

Now this is the error:

File "script.py", line 121
    transaction_clean.append(data_point.strip(" ")) 
                    ^
IndentationError: expected an indented block

Here is the code:

aily_sales_replaced = daily_sales.replace(";,;", "+")

daily_transactions = daily_sales_replaced.split(",")

daily_transactions_split = []

for transaction in daily_transactions:

  daily_transactions_split.append(transaction.split("+"))

transactions_clean = []

for transaction in daily_transactions_split:

  transaction_clean = []

  for data_point in transactions:

  transaction_clean.append(data_point.strip(" ")) 

  transactions_clean.append(transaction_clean)           

print(transactions_clean)

Double check the indentation of those two lines again, they’re still not technically inside the for loop, but just outside (and below) it, you’ll have to add an extra level for them to count as being inside the loop as intended. :slight_smile:

I have one more question. spacing is acting up on me. how do i go about fixing that?

Yeesh, one issue after another. how do the devs do it? here is the latest one:

Traceback (most recent call last):
  File "script.py", line 120, in <module>
    for data_point in transactions:
NameError: name 'transactions' is not defined
daily_sales_replaced = daily_sales.replace(";,;", "+")

daily_transactions = daily_sales_replaced.split(",")

daily_transactions_split = []

for transaction in daily_transactions:

  daily_transactions_split.append(transaction.split("+"))

transactions_clean = []

for transaction in daily_transactions_split:

  transaction_clean = []

  for data_point in transactions:

    transaction_clean.append(data_point.strip(" ")) 

    transactions_clean.append(transaction_clean)           

print(transactions_clean)

So it doesn’t look like you have a variable called transactions anywhere in the code, hence why you’re getting that error. Have a little look at some of the other variables and see if you can find what it is you should be iterating through instead. If you’re struggling a little I’ll leave a hint but I would suggest giving it a go yourself first, it’s good debugging practice after all! :slight_smile:

Hint: you want to iterate through each data point inside a single transaction