I'm new to coding so please forgive me if this question have already been answered elsewhere, but I tried looking for awhile and couldn't find an answer.
To clarify the issue I am trying to solve, I'll illustrate it with the code below:
#Sample problem
ABCD = []
KEY = "ABCD"
data = 123
[str(KEY)].append(data)
print(f"{ABCD}")
Here I am attempting to call the append method for the list ABCD but with the variable KEY which contains the string "ABCD" This code doesn't work but illustrates my question. I am wondering if it is possible to call the method such as the one I have above using a variable instead of hard coding it like:
if KEY == "ABCD":
ABCD.append(data)
print(f"{ABCD}")
Thank you!!