SESNut
SESNut

Reputation: 3

Check if "word" is in string outputted from a function

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?

Upvotes: 0

Views: 36

Answers (1)

r_batra
r_batra

Reputation: 410

It will be

if 'on' in x.values()

as this is value and not key

Upvotes: 1

Related Questions