import json
testlist = []
logpass = [1, 2, 3]
infuser = {}
infuser[logpass[0]] = {
'login': logpass[1],
'password': logpass[2]
}
testlist.append(infuser)
with open('accounts.json', 'w', encoding="utf-8") as f:
json.dump(testlist, fp=f, ensure_ascii=False, indent=4)