Jan-24-2021, 01:45 PM
In my system, this code works as expected. Can you post all of the code that is creating the error?
orders_file = open('orders.txt') orders_raw = orders_file.read() orders_file.close () orders = orders_raw.splitlines() def get_customer_orders(orders,customer_id): orders_filtered = [] for i in orders: if int(i.split(',')[2])==customer_id: orders_filtered.append(i) return orders_filtered print (get_customer_orders (orders, 256))
Output:["'2,2013-07-25 00:00:00.0,256,PENDING_PAYMENT',"]