0

I have a list of variables: [var1, var2, var3, var4].

For var1, I tried the following and it works.

d = dict(var1=True)
f = bdd.cube(d)

Now I want to loop through all variables and for each variable assign the value True. The bdd.cube function can only take the argument d fully and not as name,value separately.

I tried to do the following, but gives me an assertion error:

AssertionError: undefined variable "var", known variables are:{var1:3, var2:11, var3:2, var4:8}

for var in variables:
  d = dict(var=True):
  f = bdd.cube(d)

Please let me know how to do this.

The declaration of variables are as follows:

 Cvar           = Enum('Cvar', 'var1 var2 var3 var 4', module=__name__)

    Attributes = [CVar]
    variables = List_of_Variables(Attributes)

    def List_of_Variables(a):
      v = w = []
      for attribute in a:
        w = ['%s' %(i) for i in list(attribute)]
      return w
user3891554
  • 81
  • 2
  • 9

1 Answers1

0

This is all you need:

for var in d:
    d[var] = True

for loop will loop through all the keys in dictionary. The variable var is the current key (which is a string in this case). Then, we need to set that key's value to True.

Melvin Abraham
  • 2,870
  • 5
  • 19
  • 33