Nov-19-2018, 08:21 AM
So here I go. I'm going to try to explain this one.
I want to do a check on certain values and based upon its answer doing something.
I have a bunch of items which are dictionaries on their own.
dict = {"test": "yes", "name": "check"} (is way longer but doesn't matter)
so all the items in the list can have different values in that dictionary. ("yes" could be "no" and "name" could be anything.
letters are the dictionaries
list = ["A", "B", "C", "D"]
My goal:
check if "name" contains a certain word in those dictionaries,
--- if true
----- count the occurences:
------- 1? do something
--- if false
----- do something
Using an if-statement doesn't help me (I think) because I need a 'switch construction like in php'?
I hope it makes sense and you could share some help!
ps I can only think of:
countme = []
for i in list and i.name is "keyword":
countme = countme+1
if len(countme):
--- if len(countme) == 1
----- // do something
else
// do something
I want to do a check on certain values and based upon its answer doing something.
I have a bunch of items which are dictionaries on their own.
dict = {"test": "yes", "name": "check"} (is way longer but doesn't matter)
so all the items in the list can have different values in that dictionary. ("yes" could be "no" and "name" could be anything.
letters are the dictionaries
list = ["A", "B", "C", "D"]
My goal:
check if "name" contains a certain word in those dictionaries,
--- if true
----- count the occurences:
------- 1? do something
--- if false
----- do something
Using an if-statement doesn't help me (I think) because I need a 'switch construction like in php'?
I hope it makes sense and you could share some help!
ps I can only think of:
countme = []
for i in list and i.name is "keyword":
countme = countme+1
if len(countme):
--- if len(countme) == 1
----- // do something
else
// do something