In: Computer Science
Using Python 3. Extract the value associated with the key color and assign it to the variable color. Do not hard code this.
info = {'personal_data':
{'name': 'Lauren',
'age': 20,
'major': 'Information Science',
'physical_features':
{'color': {'eye': 'blue',
'hair': 'brown'},
'height': "5'8"}
},
'other':
{'favorite_colors': ['purple', 'green', 'blue'],
'interested_in': ['social media', 'intellectual property',
'copyright', 'music', 'books']
}
}
CODE :
OUTPUT :
Raw_Code :
info = {'personal_data':{'name': 'Lauren',
'age': 20,
'major': 'Information Science',
'physical_features':
{'color': {'eye': 'blue',
'hair': 'brown'},
'height': "5'8"}
},
'other':
{'favorite_colors': ['purple', 'green', 'blue'],
'interested_in': ['social media', 'intellectual property',
'copyright', 'music', 'books']
}
} #Given Dictonary
color = info['personal_data']['physical_features']['color']
#extracting value associated with key color and assign to variable
color
print("The Varabile Color = ",color) #printing output
***********Comment me for any Queries and Rate me up*************