0

I have two arrays, for every item in list table, I want to write data to corresponding item in list drive, inside a for loop in python

drive1 =[]

drive2 =[]

drive4 =[]

tables = ['values_1', 'values_2', 'values_4']

drive = [ drive1, drive2, drive4]

for item in tables and drive:

    tab = db[item]
3
  • what type are the elements of drive Commented Sep 10, 2018 at 11:58
  • its an array of array Commented Sep 10, 2018 at 12:00
  • 1
    what is "corresponding item" ??? Commented Sep 10, 2018 at 12:03

1 Answer 1

1

I am little confused by what you're asking, but I think this answers it...

If you just want to append to a corresponding list, try:

for item, drive_item in zip(tables, drive):
    drive_item.append(item)

Because lists are mutable, you don't need to set the return equal to anything.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.