To add a new Value to a Dictionary in Python you can use one of the following ways.
Sample Python
myDict['key'] = 'value'
or
Sample Python
myDict = {'key':'value'}
To add a new Value to a Dictionary in Python you can use one of the following ways.
myDict['key'] = 'value'
or
myDict = {'key':'value'}
To iterate a dictionary in C# and VB.NET you can use the following snippet.
var myDictionary = new Dictionary<int, string>(); myDictionary.Add(10, "Value1"); myDictionary.Add(20, "Value2"); myDictionary.Add(30, "Value3"); foreach (KeyValuePair<int, string> myPair in myDictionary) { Console.WriteLine("{0} - {1}", myPair.Key, myPair.Value); }
Dim myDictionary = New Dictionary(Of Integer, String)() myDictionary.Add(10, "Value1") myDictionary.Add(20, "Value2") myDictionary.Add(30, "Value3") For Each myPair As KeyValuePair(Of Integer, String) In myDictionary Console.WriteLine("{0} - {1}", myPair.Key, myPair.Value) Next
for more informations see KeyValuePair