Last active
November 10, 2018 01:53
-
-
Save dafinoer/17dcddf7525a4ee95a29924476cb6197 to your computer and use it in GitHub Desktop.
update dict in list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql = [(1, "Y"), (3, "T")] | |
data_json =[ | |
{ | |
'nama':'faiz', | |
'pendidikan':{ | |
'induk':1, | |
'kelas':'VII', | |
} | |
}, | |
{ | |
'nama':'ira', | |
'pendidikan':{ | |
'induk':3, | |
'kelas':'IX', | |
} | |
}, | |
{ | |
'nama':'aliya', | |
'pendidikan':{ | |
'induk':4, | |
'kelas':'VIII', | |
} | |
}, | |
] | |
for data in range(len(data_json)): | |
for data_mysql in mysql: | |
# print(data_mysql[0]) | |
if data_json[data]["pendidikan"]["induk"] == data_mysql[0]: | |
data_json[data].update({'bayar':data_mysql[1]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment