I am running a code in which I get constantly an indentation error and I don't know how to fix ...
Here my code:
L = []
def main():
L = [2, 5, 4, 8, 12, 6, 7, 10, 13]
print(L)
result = []
result = detect_ranges(L)
print(L)
print(result)
def detect_ranges(L):
list = sorted(L) # order the list ASCENDING
list2 = [] # new list to save the ranges
i = 0
while list:
print(list)
if list[i] != list[i+1] - 1:
list2.append(list[0])
list.pop([0])
elif list[i] == list[i+1] - 1:
temp = (list[0], list[i]+1)
list2.append(temp)
list.pop([i])
return list2
if __name__ == "__main__":
main()
Here is shown where is the problem and at the left are the problems