I want to split the lines in a file into 2 separate (2-dimensional) array.
E.g. Username : password array (users[user][pass])
This is the code I have come up with so far :
with open('userlist.txt', 'r') as userlist:
for line in userlist:
user, pwd = line.strip().split(':')
users = [
[user, pwd]
]
Please help. This code currently only lists all of the usernames and all of the passwords. But I want to be able to call the username with the password pair by the same index (e.g. print(users[1][1]))
user = line.strip().split(':')[0]andpwd = line.strip().split(':')[1]IF your first column in the file is always user and the second is passwordarray (users[user][pass])is rather unclear.[[user1, user2], [pwd1, pwd2]]or[[user1, pwd1], [user2, pwd2]]?