I have the following dictionary →
key : (time,edge_list)
Now I want to increase all the time values by 1. How to do this?
dict_list = dict(key:(time+1,edge_list) for key:(time,edge_list) in dict_list)
>>> d={"key" : (100,"edge_list")} >>> for i,(time,edge_list) in d.items(): ... d[i] = time+1, edge_list ... >>> d {'key': (101, 'edge_list')}
dict((key, (time + 1, edge_list)) for (key, (time, edge_list)) in somedict.iteritems())
Source: https://habr.com/ru/post/1733314/More articles:Unable to create MoveConstructibles map - c ++Removing duplicates in a string in Python - pythonInfinite Repeat Detection - language-agnosticHow to implement notification for a Windows application using .NET - c #sqlite diff-script generator - sqlОрганизация unit test в тестовом классе - unit-testingEllipse extension in nested functions: Error "..3 is used in the wrong context, no ... look in" - functionRead specific XML nodes in XML - c #What is a (scripted) language to find out if I have already started working with PowerShell? - scriptingClass method with arguments returning an array - javaAll Articles