Python list question

Hello, I have the following code for 3 variables in a list (2 values each):

account_id = [10451218925, 10001218987]
patient_name = [‘Ross,Ashley’, ‘Smith,Jane’]
dob = [20200101, 20200110]

new_list = [account_id, patient_name, dob]

for value in new_list:
print(value)

The output (as expected) would read:

[10451218925, 10001218987]
[‘Ross,Ashley’, ‘Smith,Jane’]
[20200101, 20200110]

MY DESIRED OUTPUT IS BELOW:

[10451218925, ‘Ross,Ashley’, 20200101]
[10001218987, ‘Smith,Jane’, 20200110]

How can this be accomplished?

you could loop over any of the lists (account_id for example), if you use range you can get indices, so then you can use this indices to look up the elements in the different lists.

1 Like

Looks like a good place to use zip().

2 Likes

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.