+ 3

hello guys is it possible to check if a string is among the keys of a python dictionary

like word = 'bet' main = {'a': 2, 'b': 12, 'd': 3 , 'e': 4, 't': 6} is there any way i could check if the string 'bet' (individually as characters) has a key in the dictionary, like 'b' is a key and so on

29th Jul 2019, 2:52 PM
Primidac
Primidac - avatar
1 Antwort
+ 3
something like this word = 'bet' main = {'a': 2, 'b': 12, 'd': 3 , 'e': 4, 't': 6} for each in word: if each in main.keys(): print(1)
29th Jul 2019, 3:33 PM
Steven M
Steven M - avatar