How would I make other variables True
based on what one variable contains?
Example: If I have variables:
var1 = False
var2 = False
var3 = False
var4 = False
var5 = False
And I have this next line of command:
components = w.find_element_by_id('components-val')
And components
returns as 1, 3, 5
, How do I make variables var1
, var3
, var5
all True
?
Same as if I components
return as 1
, 2
, the variables var1
and var2
would be True
You could save the numbers in a dictionary
and then update it based on your results from compontents
:
true_false = {1: False, 2: False, 3: False, 4: False, 5: False}
components = [1,2,3]
for i in components:
if i in true_false:
true_false[i] = True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.