Reputation: 650
I am trying to get the class of a dl-element. I can print the class (see the first line) but i cant use that result in an if-statement (So "works" is never printed). I guess i am somehow wrong with my syntax. Am i? Believe me that there are lot of "method"-class elements in my tests - see below
print(child.dl.get('class'))
if child.dl.get('class')=="['method']":
print("WORKS!")
This is the output of the first line:
['method']
['method']
['class']
['method']
['method']
['method']
['method']
['describe']
Upvotes: 1
Views: 216
Reputation: 473763
child.dl.get('class')
returns a list
since class
is a multi-valued attribute
.
Check if method
is inside the list:
if 'method' in child.dl.get('class', []):
print("WORKS!")
Upvotes: 1