You are trying to print out a dictionary-specific value in the list

Asked 2 years ago, Updated 2 years ago, 67 views

[{'name': 'name', 'age': 1, 'kind': 'n'}, {'name': 'value', 'age': value, 'kind': 'value'}, {'name': 'value', 'age': value, 'kind': 'value'}]

The list is stored in this way, but I don't know how to set the conditional statement to output the index of the list with the dictionary's age value of 5 or more

list dictionary python

2022-09-20 21:40

1 Answers

[i for i, d in enumerate(L) if d['age'] > 5]


2022-09-20 21:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.