0

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

enter image description here

Mia
  • 2,466
  • 22
  • 38
  • 3
    have you checked https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation – Epsi95 Jul 21 '21 at 03:28
  • 1
    Looks like you are using vscode. there should be a `Spaces` setting on the bottom bar that you can select to do 4 spaces on tab press. Or try a code formatter. – Smurphy0000 Jul 21 '21 at 03:35

0 Answers0