python dictionary dynamic key

Solutions on MaxInterview for python dictionary dynamic key by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "python dictionary dynamic key"
Lylia
25 Sep 2019
1# Dynamically naming Dictionary key, value item
2dictionaryName['static_string_' + stringVariable] = otherVariable
3
4# Example
5dictOne = {}
6strAnimal = 'dogOne'
7intAge = 7
8
9dictOne['age_of_' + strAnimal] = intAge
10# Result
11{'age_of_dogOne': 7}
12