Created
August 10, 2021 12:06
-
-
Save LukasDoesDev/fe8418de43d5918c75c33139b08b5483 to your computer and use it in GitHub Desktop.
Python range but multiple points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def range_complex(*points): | |
my_list = [] | |
prev_point = None | |
for point in points: | |
if prev_point: | |
if prev_point < point: | |
my_list.extend(list(range(prev_point, point + 1))) | |
else: | |
my_list.extend(list(range(point, prev_point))[::-1]) | |
prev_point = point | |
return my_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment