I have:
master = open('master.txt', 'r')
transaction = open('transaction.txt', 'r')
master_list = []
employee_list = []
for line in master:
# split the line
record = line.split(',')
# extract id from record
emp_id = record[0]
# add id to list
employee_list.append(emp_id)
for li in transaction:
# split the line
rec = li.split(',')
i_d = rec[3]
print(i_d)
This works as expected and outputs
001
001
001
001
001
002
002
002
002
002
003
003
003
003
003
004
004
004
004
004
005
005
005
005
005
but if I use an if statement in the nested loop like this:
for li in transaction_file:
# split the line
rec = li.split(',')
i_d = rec[3]
if i_d == emp_id:
print(emp_id)
I only get 001 001 001 001 001
why is that?