Thread Shed Problems

Hi, i followed along on this pretty well and get everything done but I kept running into a problem where the IDE kept outputting […] as lists and my code is EXACTLY what the video has. Am I going insane or missing something simple because this is driving me crazy, I’m normally good at strings!!! EDIT I never messed with anything above where it says to start coding.
URL: https://www.codecademy.com/courses/learn-python-3/projects/thread-shed

CODE:

daily_sales = \
"""Edith Mcbride   ;,;$1.21   ;,;   white ;,; 
09/15/17   ,Herbert Tran   ;,;   $7.29;,; 
white&blue;,;   09/15/17 ,Paul Clarke ;,;$12.52 
;,;   white&blue ;,; 09/15/17 ,Lucille Caldwell   
;,;   $5.13   ;,; white   ;,; 09/15/17,
Eduardo George   ;,;$20.39;,; white&yellow 
;,;09/15/17   ,   Danny Mclaughlin;,;$30.82;,;   
purple ;,;09/15/17 ,Stacy Vargas;,; $1.85   ;,; 
purple&yellow ;,;09/15/17,   Shaun Brock;,; 
$17.98;,;purple&yellow ;,; 09/15/17 , 
Erick Harper ;,;$17.41;,; blue ;,; 09/15/17, 
Michelle Howell ;,;$28.59;,; blue;,;   09/15/17   , 
Carroll Boyd;,; $14.51;,;   purple&blue   ;,;   
09/15/17   , Teresa Carter   ;,; $19.64 ;,; 
white;,;09/15/17   ,   Jacob Kennedy ;,; $11.40   
;,; white&red   ;,; 09/15/17, Craig Chambers;,; 
$8.79 ;,; white&blue&red   ;,;09/15/17   , Peggy Bell;,; $8.65 ;,;blue   ;,; 09/15/17,   Kenneth Cunningham ;,;   $10.53;,;   green&blue   ;,; 
09/15/17   ,   Marvin Morgan;,;   $16.49;,; 
green&blue&red   ;,;   09/15/17 ,Marjorie Russell 
;,; $6.55 ;,;   green&blue&red;,;   09/15/17 ,
Israel Cummings;,;   $11.86   ;,;black;,;  
09/15/17,   June Doyle   ;,;   $22.29 ;,;  
black&yellow ;,;09/15/17 , Jaime Buchanan   ;,;   
$8.35;,;   white&black&yellow   ;,;   09/15/17,   
Rhonda Farmer;,;$2.91 ;,;   white&black&yellow   
;,;09/15/17, Darren Mckenzie ;,;$22.94;,;green 
;,;09/15/17,Rufus Malone;,;$4.70   ;,; green&yellow 
;,; 09/15/17   ,Hubert Miles;,;   $3.59   
;,;green&yellow&blue;,;   09/15/17   , Joseph Bridges  ;,;$5.66   ;,; green&yellow&purple&blue 
;,;   09/15/17 , Sergio Murphy   ;,;$17.51   ;,;   
black   ;,;   09/15/17 , Audrey Ferguson ;,; 
$5.54;,;black&blue   ;,;09/15/17 ,Edna Williams ;,; 
$17.13;,; black&blue;,;   09/15/17,   Randy Fleming;,;   $21.13 ;,;black ;,;09/15/17 ,Elisa Hart;,; $0.35   ;,; black&purple;,;   09/15/17   ,
Ernesto Hunt ;,; $13.91   ;,;   black&purple ;,;   
09/15/17,   Shannon Chavez   ;,;$19.26   ;,; 
yellow;,; 09/15/17   , Sammy Cain;,; $5.45;,;   
yellow&red ;,;09/15/17 ,   Steven Reeves ;,;$5.50   
;,;   yellow;,;   09/15/17, Ruben Jones   ;,; 
$14.56 ;,;   yellow&blue;,;09/15/17 , Essie Hansen;,;   $7.33   ;,;   yellow&blue&red
;,; 09/15/17   ,   Rene Hardy   ;,; $20.22   ;,; 
black ;,;   09/15/17 ,   Lucy Snyder   ;,; $8.67   
;,;black&red  ;,; 09/15/17 ,Dallas Obrien ;,;   
$8.31;,;   black&red ;,;   09/15/17,   Stacey Payne 
;,;   $15.70   ;,;   white&black&red ;,;09/15/17   
,   Tanya Cox   ;,;   $6.74   ;,;yellow   ;,; 
09/15/17 , Melody Moran ;,;   $30.84   
;,;yellow&black;,;   09/15/17 , Louise Becker   ;,; 
$12.31 ;,; green&yellow&black;,;   09/15/17 ,
Ryan Webster;,;$2.94 ;,; yellow ;,; 09/15/17 
,Justin Blake ;,; $22.46   ;,;white&yellow ;,;   
09/15/17,   Beverly Baldwin ;,;   $6.60;,;   
white&yellow&black ;,;09/15/17   ,   Dale Brady   
;,;   $6.27 ;,; yellow   ;,;09/15/17 ,Guadalupe Potter ;,;$21.12   ;,; yellow;,; 09/15/17   , 
Desiree Butler ;,;$2.10   ;,;white;,; 09/15/17  
,Sonja Barnett ;,; $14.22 ;,;white&black;,;   
09/15/17, Angelica Garza;,;$11.60;,;white&black   
;,;   09/15/17   ,   Jamie Welch   ;,; $25.27   ;,; 
white&black&red ;,;09/15/17   ,   Rex Hudson   
;,;$8.26;,;   purple;,; 09/15/17 ,   Nadine Gibbs 
;,;   $30.80 ;,;   purple&yellow   ;,; 09/15/17   , 
Hannah Pratt;,;   $22.61   ;,;   purple&yellow   
;,;09/15/17,Gayle Richards;,;$22.19 ;,; 
green&purple&yellow ;,;09/15/17   ,Stanley Holland 
;,; $7.47   ;,; red ;,; 09/15/17 , Anna Dean;,;$5.49 ;,; yellow&red ;,;   09/15/17   ,
Terrance Saunders ;,;   $23.70  ;,;green&yellow&red 
;,; 09/15/17 ,   Brandi Zimmerman ;,; $26.66 ;,; 
red   ;,;09/15/17 ,Guadalupe Freeman ;,; $25.95;,; 
green&red ;,;   09/15/17   ,Irving Patterson 
;,;$19.55 ;,; green&white&red ;,;   09/15/17 ,Karl Ross;,;   $15.68;,;   white ;,;   09/15/17 , Brandy Cortez ;,;$23.57;,;   white&red   ;,;09/15/17, 
Mamie Riley   ;,;$29.32;,; purple;,;09/15/17 ,Mike Thornton   ;,; $26.44 ;,;   purple   ;,; 09/15/17, 
Jamie Vaughn   ;,; $17.24;,;green ;,; 09/15/17   , 
Noah Day ;,;   $8.49   ;,;green   ;,;09/15/17   
,Josephine Keller ;,;$13.10 ;,;green;,;   09/15/17 ,   Tracey Wolfe;,;$20.39 ;,; red   ;,; 09/15/17 ,
Ignacio Parks;,;$14.70   ;,; white&red ;,;09/15/17 
, Beatrice Newman ;,;$22.45   ;,;white&purple&red 
;,;   09/15/17, Andre Norris   ;,;   $28.46   ;,;   
red;,;   09/15/17 ,   Albert Lewis ;,; $23.89;,;   
black&red;,; 09/15/17,   Javier Bailey   ;,;   
$24.49   ;,; black&red ;,; 09/15/17   , Everett Lyons ;,;$1.81;,;   black&red ;,; 09/15/17 ,   
Abraham Maxwell;,; $6.81   ;,;green;,;   09/15/17   
,   Traci Craig ;,;$0.65;,; green&yellow;,; 
09/15/17 , Jeffrey Jenkins   ;,;$26.45;,; 
green&yellow&blue   ;,;   09/15/17,   Merle Wilson 
;,;   $7.69 ;,; purple;,; 09/15/17,Janis Franklin   
;,;$8.74   ;,; purple&black   ;,;09/15/17 ,  
Leonard Guerrero ;,;   $1.86   ;,;yellow  
;,;09/15/17,Lana Sanchez;,;$14.75   ;,; yellow;,;   
09/15/17   ,Donna Ball ;,; $28.10  ;,; 
yellow&blue;,;   09/15/17   , Terrell Barber   ;,; 
$9.91   ;,; green ;,;09/15/17   ,Jody Flores;,; 
$16.34 ;,; green ;,;   09/15/17,   Daryl Herrera 
;,;$27.57;,; white;,;   09/15/17   , Miguel Mcguire;,;$5.25;,; white&blue   ;,;   09/15/17 ,   
Rogelio Gonzalez;,; $9.51;,;   white&black&blue   
;,;   09/15/17   ,   Lora Hammond ;,;$20.56 ;,; 
green;,;   09/15/17,Owen Ward;,; $21.64   ;,;   
green&yellow;,;09/15/17,Malcolm Morales ;,;   
$24.99   ;,;   green&yellow&black;,; 09/15/17 ,   
Eric Mcdaniel ;,;$29.70;,; green ;,; 09/15/17 
,Madeline Estrada;,;   $15.52;,;green;,;   09/15/17 
, Leticia Manning;,;$15.70 ;,; green&purple;,; 
09/15/17 ,   Mario Wallace ;,; $12.36 ;,;green ;,; 
09/15/17,Lewis Glover;,;   $13.66   ;,;   
green&white;,;09/15/17,   Gail Phelps   ;,;$30.52   
;,; green&white&blue   ;,; 09/15/17 , Myrtle Morris 
;,;   $22.66   ;,; green&white&blue;,;09/15/17"""

#------------------------------------------------
# Start coding below!
daily_sales_replaced = daily_sales.replace(";,;","+")

daily_transactions = daily_sales_replaced.split(",")
#print(daily_transactions)

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

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

OUTPUT:
['Myrtle Morris \n', [...], '$22.66', [...], 'green&white&blue', [...], '09/15/17', [...]]

What am I doing wrong?!

2 Likes

Check if your lists contain themselves, for example:

a = []
a.append(a)
print(a)
print(a[0] is a)
2 Likes

I started from scratch just following the directions and though i understand them better, I am getting a syntax error that makes no sense to me. Here is the URL and underneath is a screen-shot with the complete code and error. Screenshot%20from%202018-12-27%2016-31-04
EDIT I think last time i just went too fast through it and didn’t read the instructions well enough…Lesson learned.

URL: https://www.codecademy.com/courses/learn-python-3/projects/thread-shed

1 Like

So you’ve put quotes around the dot in line 112?

1 Like

I was trying different things and deleted them but yes i did, just did it again for the screenshot

1 Like

So then the real error surfaces.

1 Like

That’s an extremely helpful error message, read what it has to say and then think about whether that sounds right, and consider what you think needs to be different in that situation to match what you meant

(by helpful I mean that it says exactly what the problem is, a non-programmer might think that “helpful” means a suggestion on how to correct it but that is absolutely not something that a computer can know what you meant so a suggestion would be incredibly unhelpful. coming up with what to do next comes from understanding the situation and comparing it to what you meant, the difference (subtraction, essentially) is the change that you need to make)

I know languages that will just tell you:

?

If you do something wrong like this.

1 Like

This is going directly over my head, it’s quite frustrating. Are you saying i need to add another line for context? he says with a fear of sounding dumb

1 Like

No I mean that your line which is triggering that error message has some intention behind it (your intention)
Your error message explains why you can’t do what you wrote.

So first thing is to decide whether you agree with the error message that this is indeed not possible.
And then you’d compare your intention to this situation, what did you mean should be different?

1 Like

It says a list has no split attribute.

Are you calling split on a list?

Does a list have a split attribute?

1 Like

There is a feeling of haste and I don’t know why, but it tends to happen when i ask for help. Since it says to split around commas I keep getting lost. Like my brain throws a syntax error of it’s own.

1 Like

You can’t possibly start guessing at what a solution would be before sorting out what the current situation is.

You’re attempting to use a method named split.
Does that value have such a method? (your error message tells you all about this, it doesn’t)
So either you thought this type does have such a method, or you thought it was a different type. <- this says a whole lot about what you need to change

Or if you just don’t know what you meant that your line of code should do, then you have to figure out that before anything else. Can’t write code without knowing what it is you want to make happen.

1 Like

How about looking at the value, printing it out.

I’m starting to get the sense that what’s “wrong” about the whole situation is that you’ve lost touch with intention. (Like I said a few minutes ago, it makes no sense at all to write code without intention)
And if that’s indeed the case then you need to re-sync on what’s supposed to happen.
Codecademy doesn’t help with this because of how it says “do this, do that” while skipping out on telling you on what’s being done. Yet, by reading the instructions you can get yourself an idea of what’s supposed to happen, and then you can write code based on that

1 Like

I see commas in the replaced sales so i just don’t get it… I guess I just have to go back to the string method because i guess I’m missing something.

1 Like

Sure there are commas in some form or another.
But what data type is the whole value, and what operations does that value type support? And, what kind of operation are you looking for, and how does that relate to what you currently have in your value? Maybe it needs to be restructured in some way, or maybe it wasn’t supposed to be structured that way in the first place, or maybe that’s not at all the action you’re supposed to be doing.

“I have a number, and my intention is to add 5 to it. This makes sense because numbers support this operation, and the way that numbers expose this behaviour is through the + operator”

1 Like

I need a for loop because i changed the data type from string to list…right?

1 Like

No idea. No clue what you’re doing (no, don’t tell me)
This is where intention comes in. What did you mean.

1 Like

I thought you were going to tell me i was right lol
I’m trying to split " daily_transactions_replaced" at the commas and put it into a new list.

1 Like

Nope, I’ll do no such thing.
The decision of what to do is, I’m sure, entirely trivial. It’s not really related to programming. It’s more like going to the kitchen for some water to drink and having to figure out how to carry the water. You’ll need a container you can carry, a glass would be nice.
You just need to compare the right things, ie what you currently have, what you’re looking to change about it, what operations make sense to do with what you have, what operations you need to carry out.

Once you’ve got your intentions straightened out, and you’ve reasoned about that it makes sense, then comes the next step of translating to code. Yes, that’s entirely separate from deciding what to do, and the deciding part has to be done first for obvious reasons.

1 Like

I believe you’re making sense but i’m currently trying to translate it into code. The way you explained it (thanks by the way) made me think about it this way “Why would i add(append) water to a glass ( empty list ) BEFORE I put it through the filter to take out the junk (delimiter)”
Hopefully that’s right and i can mark this solved.

1 Like