l = [100, 200, 300, 400, ,500]
if a <= 100:
y = 0
elif a <= 200:
y = 1
elif a <= 300:
y = 2
elif a <= 400:
y = 3
else:
y = 4
def group_place(a):
l = [100, 200, 300, 400, 500]
for i in range(0, len(l)):
if a <= l[i]: break
return i
def get_group(value, sorted_list):
for i breakpoint in enumerate(sorted_list):
if value < breakpoint:
return i
# a value greater than the last in the list
return len(sorted_list)
l = [100, 200, 300, 400, 500]
print(get_group(215, l))
import bisect
print(bisect.bisect_left(l, a))
def r(a, l):
b = 0
for i, d in enumerate(l):
if a > d:
b = i + 1
return b
l = [100, 200, 300, 400, 500]
x = 288
print(min([ind for ind, i in enumerate(l) if i > x]))
(value - 1)/100
Find more questions by tags Python