I have a data vector data = [x for x in range(0,999)]
what I want to do is that to, access elements in data
according to a given value
e.g if value=10
access 0th index of data
and if value=20
access 1st index of data
. It is supoused to be something like this:
def get_data(value):
if value ==10:
return data[0]
elif value == 20:
return data[1]
elif value ==30:
return data[2]
But in reality, i will have really big data and I cannot keep putting elif
statements. Is there any efficient way of doing this?