I have a list of statements
a = "hello"
b = "hi"
c= "test"
In a program I got variable name(a,b or c) and need to return value of variable using that function method.
def my_method(item):
a = "hello"
b = "hi"
c= "test"
item parameter will be either a , b or c and I need to return value of that item. Is there any technique to return item value without if condition for three statement?
d = {'a':'hello', 'b':'hi', 'c':'test'}, then directly look it up withd[key]. Or a list.dict('a':'hello', 'b':'hi', 'c':'test').get. No need to declare a new function.)