You can use `1 <= build_number <= len(builds)`. That would simplify this construct a lot.