Thread Shed String Project readability

Hey there!

I’m currently on the Thread Shed project practicing how to use strings in Python and while trying to print a result to see if I got the correct answer, something unexpected was printed instead.

Please see the result printed into the console:
<built-in method strip of str object at 0x7fae81d6f8a0>, <built-in method strip of str object at 0x7fae81d728b0>, <built-in method strip of str object at 0x7fae81d6f918> - and so on in the same format.

I remember in a previous lesson that there is a way to read the data by finding it on the hard drive, I just can’t remember what it is or what it’s called (and don’t want to go through all the lessons again in all honestly :sweat_smile:)
My written code so far:

daily_sales_replaced = daily_sales.replace(';,;', '--')
# print(daily_sales_replaced)

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

daily_transactions_split = []
for trans in daily_transactions:
  daily_transactions_split.append(trans.split('--'))
# print(daily_transactions_split)

transactions_clean = []
for unit in daily_transactions_split:
  transactions_clean.append(str(unit).strip)
print(transactions_clean)

I would really appreciate some assistance :upside_down_face:

Wishing you all a great further day!

P.S. Here’s the link to the project

You have .strip instead of .strip()
so you’re printing the method (function) instead of the result of that .strip method (meaning what gets returned by the .strip )

Ah, I see, thank you!

I made the change but the result didn’t remove the excess whitespace like it was supposed to. I then removed the str() function to see if that would change anything and got the following error:

AttributeError: 'list' object has no attribute 'strip'

I’m not understanding what I’m doing wrong… in the lessons it works without using str() and then there’s the issue that .strip() isn’t removing the excess whitespace :sweat_smile:

Do you know how to fix this part or what might be causing this issue?

daily_transactions_split is a 2D list (a list of lists) of strings
so you’d need a loop inside a loop to deal with the strings.

transactions_clean = []
for trans in daily_transactions_split:
  for unit in trans:
    transactions_clean.append(unit.strip())
1 Like

Ohhh, I seeee

That’s incredible, thank you so much!