I have multiple variables with values that I like to access with the output from a string. I can get the string value but don't know how to convert the string "P2", so I can print or access the content of variable P2.
been searching for different ways to print lists and been using for loops, but I am lost, and can not find a solution.
P1 = [1.123, 10.34, 48.61]
P2 = [2.22, 11.34, 49.61]
P3 = [3.32, 12.34, 50.61]
g_line = ["N30","G54.1","P2",";\n"]
def work_zero_p_num():
for k, line in enumerate(g_line):
if "P" in line:
get_cur_work = line
print(get_cur_work) # This line prints value "P2",
work_zero_p_num()
the output i like to have is;
print(P2)
[2.22, 11.34, 49.61]
what i get from my code is
print(get_cur_work)
P2