I have a list made out of tuples such as the one below:
(2809.3994479562093, 1032.5989696312365, 0.0), {'level': '2', 'id': '1'})
having a sett of different values for the level key in the dictionary(increasing, but not always integers i.e. 1, 2, 3, 3B, 4A, 5, 5A, 6, 7), the id increasing incrementally and consists only of integers.
what I'm trying to find out is the value of the first two values in the first element of the tuple i.e the floating points 2809.399... and 1032.5989... in the case of the level being +/- 1 different from the ones I'm currently at. In other words, level 2 id 1 should be looking for id 1 on levels 1 and 3.
What I've come up with for this is the following:
for x in xrange(len(net.lifts)):
if net.lifts[x][1]["level"] == "2":
for y in xrange(len(net.lifts)):
if (net.lifts[y][1]["level"] == "1" or net.lifts[y][1]["level"] == "3") and net.lifts[y][1]["id"] == net.lifts[x][1]["id"]:
print "edge:" + str(net.lifts[x][0][:2]) + str(net.lifts[y][0][:2])
and it works. However it requires me to define long if statements for each of the case. Is there a more efficient way (algorithm) of abstracting this without having to create 7 if loops (one for each level)?