How can I remove an object from array in python?
I want to select an msgID and want to delete that full object with username, msg, time_stamp (all of it).
room_msg = [
{
'msgID': 1,
'username': 'User1',
'msg': 'msg1',
'time_stamp': 'May-31 05:29PM'},
{
'msgID': 2,
'username': 'User2',
'msg': 'msg2',
'time_stamp': 'May-31 05:29PM'},
{
'msgID': 3,
'username': 'User3',
'msg': 'msg3',
'time_stamp': 'May-31 05:29PM'} ]
Like if I select 'msgID': 3
after deleting the 'msgID': 3
the array should like this
room_msg = [
{
'msgID': 1,
'username': 'User1',
'msg': 'msg1',
'time_stamp': 'May-31 05:29PM'},
{
'msgID': 2,
'username': 'User2',
'msg': 'msg2',
'time_stamp': 'May-31 05:29PM'}
]
Is that possible?
I can't find x with that msgID room_msg[x]
.