here is what I want to do:
b=1
har1=42
print(f"har{b}")
I want it to display 42
I have tried a few things, but I haven't managed to get it to work
here is what I want to do:
b=1
har1=42
print(f"har{b}")
I want it to display 42
I have tried a few things, but I haven't managed to get it to work
Use either globals() or locals() and construct the key string.
b=1
har1=42
globals()['har'+str(b)]
def f():
b=1
har1=42
print(locals()['har'+str(b)])
f()