How can the value of a variable in Python refer back to a variable again?

Asked 2 years ago, Updated 2 years ago, 85 views

 A='var A'
 B='A'
print(B)
del B

I want to delete A by referring to variable A as 'A', which is the value of variable B. What's the way?

reference variable

2022-09-22 19:28

1 Answers

A='var A'
B='A'

print(A)
del locals()[B]
print(A)

Wouldn't it be possible in the same way?


2022-09-22 19:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.