Python - injecting data into for loop -
i have following list:
users = [ "user1", "user2", "user3" ]
and have loop, loops through another list:
for item in ids: myfunction(item, user) # ???
i'm not sure how make loop. want to is, each item loop goes through, should execute myfunction(item, user)
, user variable should user users list, , each item, user should not same (when gets end of users list, may come user1, , repeat loop).
it should execute this:
myfunction(item, "user1") myfunction(item, "user2") myfunction(item, "user3")
how can achieve this?
thank you
for counter, item in enumerate(ids): user = users[counter % len(users)] myfunction(item, user)
Comments
Post a Comment