While I was doing a Python exercise at the learn Python course I got stuck during one of the exercise requirements. In this exercise I should create a loop that is able to iterate trough a list of strings and append each string to other lists that should contain that type of string. For example if the string is a name, it should be appended to the customer list, if its a money value, it should be appended to the price list. I tried to think of many solutions, for example:
index = 0 for transaction in transactions_clean: customers.append(transaction[index]) index += 1 sales.append(transaction[index]) index += 1 thread_sold.append(transaction[index]) index += 1 date.append(transaction[index]) if index == 700: break
transactions_list =  customers =  sales =  thread_sold =  date =  transactions_list.append(customers) transactions_list.append(sales) transactions_list.append(thread_sold) transactions_list.append(date) for list in transactions_list: for data in transactions_clean: list.append(data)
But still none of the solutions worked, I even tried to convert it in a list of lists and aply the same method i did in the first example, but I keept geting a message error saying that the index was out of range. Does anyone know how to create a loop that does what I need for this exercise?