我有2个列表,并希望根据该列表中的项目数(我的代码)进行for循环:
accounts = []
passwords = []
entry1= input('Accounts : ').split()
entry2= input('Passwords : ').split()
accounts.extend(entry1)
passwords.extend(entry2)
我想做的事:
for account in accounts and password in passwords:
# do something that matchs accounts[n] with passwords[n] each loop
最佳答案
听起来像您想要zip()
函数:
accounts = input('Accounts : ').split()
passwords = input('Passwords : ').split()
for account, password in zip(accounts, passwords):
#do stuff with account and password