To display the value of the key "year" using the get
method in the given code, you would use the following line:
print(user.get('subscription').get('valid_till').get('year'))
Here’s a breakdown of each part:
user.get('subscription')
retrieves the value associated with the 'subscription' key..get('valid_till')
accesses the 'valid_till' dictionary within the subscription..get('year')
finally retrieves the value associated with the 'year' key within 'valid_till'.
So the correct response is:
print(user.get('subscription').get('valid_till').get('year'))