Python 3 course: Strings section: Thread Shed project

Hello everyone!

My question concerns the following linked project:

My problem originates at step 3, after only the following 3 lines of code:

daily_sales_replaced = daily_sales.replace(";,;", “&”)
daily_transactions = daily_sales_replaced.split(",")

For some reason, the .split() function is adding many ‘\n’ into my output that don’t exist in the data prior to that operation. I’ve corroborated my code with the code provided in the Codecademy companion video, and it seems to be the same. I continued in spite of the extra newlines until step 14, when I’m supposed to sum the values included in the Sales list, but because of the many ‘\n’ I’m unable to convert a lot of these numeric strings into actual float values. Does anyone have guidance on why the ‘\n’ are being added by the .split() function in step 3? Barring that, does anyone have advice for how to perform a built-in string function to remove the newlines from my data output?

Thanks much! (My first time posting in these forums, so apologies if my question is formatted/documented incorrectly!)

The new line characters are expected. Did you perhaps skip over instruction #8 where you use .strip()?

1 Like

Thanks midlindner! That solved my problem :slight_smile: