python how to make range include end boundary

Viewed 2574

I am trying to make range include end boundary,

if distance == 1:
     end_boundary = int(d + distance + distance)
else:
     end_boundary = int(d + distance + distance - 1)

for y in range(int(d - distance), end_boundary):
    # some other code

d contains int value, I am wondering if there is a better way to do this.

Also I want to make this code work when d and distance contains float values.

0 Answers
Related