python - More pythonic method of indexing with a list of coordinates -
so designing program needs index nested list, using stored list of coordinates:
e.g
coordinate = [2,1]
for function returns element in nested list, use
return room[coordinate[0]][coordinate[1]]
my programming instincts tell me seems overly long, , there should shorter method of doing in python, can't seem find of sort. know if there method this?
you can unpack coordinates more 1 variable.
i, j = [2, 1] return room[i][j]
or
coordinates = [2, 1] ### stuff coordinates i, j = coordinates return room[i][j]
Comments
Post a Comment