Use variable as a key : Dictionary Key « Dictionary « Python






Use variable as a key

Use variable as a key
 
table = {'Python':  'Guido van Rossum',
          'Perl':    'Larry Wall',
          'Tcl':     'John Ousterhout' }

language = 'Python'
creator  = table[language]
print creator



           
         
  








Related examples in the same category

1.Dictionary: create a new list of keysDictionary: create a new list of keys
2.For loop through the dictionary keysFor loop through the dictionary keys
3.Dictionary: The keys, values, and items FunctionsDictionary: The keys, values, and items Functions
4.Sorting Keys: for Loops
5.Dictionary Keys Are Case-SensitiveDictionary Keys Are Case-Sensitive