What I am trying to do is to check if a string input is in dictionary, which values are in lists:
data_dict = {'mobile_panel': ["APP", "DTRAFFIC", "DSCHANGE", "SEARCH", "URL", "HTTP", "ALL"],
'socio': ["-20.000 inh", "20.000-50.000 inh", "50.000-100.000 inh", "100.000 inh or more"]}
This is the dictionary. I want to create a functions for every key:value pair:
def mob_panel_in_list(string):
for key, value in data_dict.items():
if string in 'mobile_panel':
return string
else:
return string + '_not_valid'
The next function to be for key - 'socio' and so on. The problem is that this function always returns the else statement. When I change 'mobile_panel' with value, I am getting the correct result, but this works only for the first key:value pair. How can I select the different keys and their values? I am missing something, but can't figure it out.