Here is my code up until the point I think I did something weird in this exercise:
#print(daily_sales)
daily_sales_replaced = daily_sales.replace(";,;", ";")
#print(daily_sales_replaced)
daily_transactions = daily_sales_replaced.split(",")
#print(daily_transactions)
daily_transactions_split = []
for i in range(len(daily_transactions)):
splitted = daily_transactions[i].split(";")
daily_transactions_split.append(splitted)
#print(daily_transactions_split)
transactions_clean = []
for index in range(len(daily_transactions_split)):
for words in daily_transactions_split[index]:
spliited = words.strip()
transactions_clean.append(spliited)
print(transactions_clean)
customers = []
sales = []
thread_sold = []
for index in range(len(transactions_clean)):
if index % 4 == 0:
customers.append(transactions_clean[index])
elif (index - 1) % 4 == 0:
sales.append(transactions_clean[index])
elif (index - 2) % 4 == 0:
thread_sold.append(transactions_clean[index])
The output of transactions_clean was not a 2d list. I got the impression after reading through my tasks that it was meant to be a 2d list with a name, sale, colour thread and date each in its own separate list inside the 2d list.
As it turns out I was fine and managed to get the lists for customers, sales, and threads sold correct anyway. But I’m just wondering now after finishing the exercise how I would have simultaneously made a list which cleaned up daily_transactions_split with strip() and preserved the 2d nature of daily_transactions_split.
Thanks in advance