In the interest of efficiency, I'd like to be able to use an argument given when calling my function to determine which variables the function tries to get the values of without copy and pasting the same code 5 times but changing some numbers in the variables. e.g.
variable1 = "hello"
variable2 = "goodbye"
function(number):
return(variable(number))
so ideally if i called function(2)
it would return variable2
. Is there a way to do this? Or should I just duplicate my code and change the variable number for each time I want to do this?