https://www.codecademy.com/courses/learn-python-3/projects/thread-shed
I am currently working on this project and got to step 6. I entered my code, which seemed right, and matches the code from the walkthrough video, but it comes up as an empty list when it should be a very full list.
help|474x107
When I print it, the terminal comes up with just “” when it should be 100+ lines of text. I’m very confused on what I’m doing wrong. Anything helps, thank you!
Hello @itsjackbox, welcome to the forums! Could you please post your full code? To format it correctly, press this button:
and put the code between the back ticks:
1 Like
Sorry, will post full code here.
daily_sales_replaced = daily_sales.replace(";,;", "+")
daily_transactions = daily_sales_replaced.split(",")
#print(daily_transactions)
daily_transactions_split = []
for transaction in daily_transactions_split:
daily_transactions_split.append(transaction.split("+"))
print(daily_transactions_split)```
daily_transactions = daily_sales_replaced.split(",")
daily_transactions_split = []
for transaction in daily_transactions_split:
daily_transactions_split.append(transaction.split("+"))
You should think about how the for-loop is working here. for transaction in daily_transactions_split
is going to iterate through daily_transactions_split
, but what value do you have assigned to it?
2 Likes
The transaction
is each group of units split by the +
Sorry, I still don’t really understand the issue
I’ll word it differently.
Let’s look at what happens in the code:
- you declare
daily_transactions_split
to be an empty list
- you write a for-loop that will cycle through
daily_transactions_split
. But it’s an empty list…
@itsjackbox
What happens when you write this?
for transaction in daily_transactions_split:
print(transaction)
Then consider… what happens when you write this?
for transaction in daily_transactions:
print(transaction)
1 Like
Wow I just realized how incredibly wrong I am. Thanks for helping me realize, just a massive brain fart I guess.
2 Likes
It happens, no worries!
@itsjackbox welcome to the forums!
Thank you
Learning coding has been very fun so far
1 Like
I know the feeling!! Getting through the brain farts… lol 