vendredi 10 juillet 2020

is there a way to write a one liner if-statement, involving for-statement on all items based on a specific value == False? [duplicate]

I am trying to find an effective condition statement which executes code.

I am looking at something along the lines of,

if for all in list[1]['purchased'] == False:
    main()

I Have items inside a list which are all nested lists. Each nested list consists of two dictionaries, whereby the 2nd dictionary has a KEY "purchased". this is consistent for every item in the main list.

Example:

Main_list = [[{'time': str, 'price': int},{'name': "Bob", 'stock purchased': bool}], 
[{'time': str, 'price': int}, {'name': "Bob", 'stock purchased': bool}]]

Any help would be much appreciated!

kindest regards, Andrew

Aucun commentaire:

Enregistrer un commentaire