I am looking for a way to update list listOfuser
with dict User without over writing any last index.
[{'name': 'john', 'fimily': 'johny', 'studentId': '2120', 'age': 23},
{'name': 'mick', 'fimily': 'micky', 'studentId': '2121', 'age': 24}]
Result which I currently have:
[{'name': 'mick', 'fimily': 'micky', 'studentId': '2121', 'age': 24},
{'name': 'mick', 'fimily': 'micky', 'studentId': '2121', 'age': 24}]
Code snippet used to produce the said result:
UserInfo = {}
listOfUser = []
UserInfo['name'] = "john"
UserInfo['fimily'] = 'johny'
UserInfo['studentId'] = '2120'
UserInfo['age'] = 23
listOfUser.append(UserInfo)
print(listOfUser)
UserInfo['name'] = "mick"
UserInfo['fimily'] = 'micky'
UserInfo['studentId'] = '2121'
UserInfo['age'] = 24
listOfUser.append(UserInfo)
print(listOfUser)
is there any way ?