I want to add username and dateTimeHold to bigData, if it already exists, then I only want to add dateTimeHold, else add username and dateTimeHold.
When I'm trying with this code, it's just overwriting:
dateTimeHold = ('09-07-2019', '09.00 - 16.00', 'Red')
username = 'James'
bigData = {
'Peter': [('08-07-2019', '06.00 - 07.00', 'Blue')],
'James': [('08-07-2019', '06.00 - 07.00', 'Blue')]
}
if username != bigData.keys():
listTime = []
listTime.append(dateTimeHold)
bigData[username] = listTime
else:
bigData[username][listTime].append(dateTimeHold)
Output:
{
'Peter': [('08-07-2019', '06.00 - 07.00', 'Blue')],
'James': [('09-07-2019', '09.00 - 16.00', 'Red')]
}
What I want it to do:
{
'Peter': [('08-07-2019', '06.00 - 07.00', 'Blue')],
'James': [('08-07-2019', '06.00 - 07.00', 'Blue'), ('09-07-2019', '09.00 - 16.00', 'Red')]
}