0

I have a function in variable x which returns

{'activeTime': 106, 'deviceStatus': 'on', 'power': 'f29b:f19e', 'energy': 0.02, 'voltage': '7b2ba:7b366', 'deviceImg': ''}

so then I put

if 'on' in x:
    print('on')

but it doesnt print on, what am i missing?

SESNut
  • 3
  • 2
  • 4
    Possible duplicate of [How to check if a value exists in a dictionary (python)](https://stackoverflow.com/questions/8214932/how-to-check-if-a-value-exists-in-a-dictionary-python) – Andreas Jul 22 '19 at 04:03

1 Answers1

1

It will be

if 'on' in x.values()

as this is value and not key

r_batra
  • 400
  • 3
  • 14