I have run the below code:
def test(yymm):
exec("test_var_" + yymm + " = 'abc'")
print(test_var_1912)
test('1912')
My expected output is to assign the variable 'test_var_1912' and print out string "abc". However, Python prompt the below error message:
NameError: name 'test_var_1912' is not defined
Could anyone please help to solve my question?