Got some basic problems with looping through the list of dictionaries. I want to loop through the list called jslist and get an output as I show at the bottom. Basically I want to extract chosen key: value pairs (the ones I paste as an example below - site_id, sitekey, nickname) from the list and store them in another list of dicts.
jslist = [
{'site_id': '1111111', 'hostname': 'abc.com', 'nickname': 'abc.com', 'sitekey': '29346385345', 'sitekey_admin': '293857349857934857345', 'timezone': '1', 'visitors_online': '1', 'visitors_today': '34'},
{'site_id': '100992048', 'hostname': 'gcd.com', 'nickname': 'gcd.com', 'sitekey': '938573945739453', 'sitekey_admin': '20395734985793', 'timezone': '1', 'visitors_online': '0', 'visitors_today': '2'}]
dict_1 = {}
for k in jslist:
dict_1['site_id'] = k['site_id']
dict_1['sitekey'] = k['sitekey']
dict_1['nickname'] = k['nickname']
print(list(dict_1))
current output:
{'site_id': '100992048', 'sitekey': '938573945739453', 'nickname': 'gcd.com'}
expected output
[{'site_id': '100992048', 'sitekey': '938573945739453', 'nickname': 'gcd.com'},{'site_id': '1111111', 'sitekey': '29346385345', 'nickname': 'abc.com'}]