[Solved] Nested dictionaries

How can I access the keys inside of a dictionary?

For example:

 films = {'Finding Dory':{'age':15, 'ticket':5}}

And I would like to check if there are enough tickets

  if numberOfTickets > 0:
         any action here...

Hello tehuan.

Depending on how consistent your object is:

for key in films:
  if films[key]['ticket'] > 0:
    # Do something

I would add in a check to make sure that 'ticket' is in films.

I hope this helps

@Sky020 Thank you so much for your help!
I’m sorry about my questions, I’m totally beginner.
I understood how to access the key as the example below.

films = {'Finding Dory':{'age':15, 'ticket':5}}

if films['Finding Dory']['ticket'] > 0:
    print('Working fine')

But now Im a bit confuse about how to check if the key ‘ticket’ is in films. Can you show me please using a if statment?