a = "Jack"
b = "Sam"
Now I want some way to create this:
c_{b value} = 10
That means:
c_Jack = 10
And the following:
c_{a value} = 20
That means:
c_Sam = 20
a = "Jack"
b = "Sam"
Now I want some way to create this:
c_{b value} = 10
That means:
c_Jack = 10
And the following:
c_{a value} = 20
That means:
c_Sam = 20
This is actually a bad practice to do this. You better to use a dict
.
BTW, you can do this:
In [3]: a = "Jack"
In [4]: exec(f'c_{a} = 10')
In [5]: c_Jack
Out[5]: 10