Python indentation error when creating a list
Question: I am getting an indentation error and I cant see why, I defined two lists of
dicts, the first one is fine, but the second one (which follows the same
format) is throwing an indentation error.

list one (no problems):

    
    
    itemData = [{'id': 11, 'model': 'm1', 'serial': 'ser123', 'location': 3, 'distance': 2, 'loc': 3},
                {'id': 12, 'model': 'm1', 'serial': 'ser456', 'location': 3, 'distance': 2, 'loc': 3}]
    

first version of list two:

    
    
    itemData2 = [{'id': 11, 'model': 'm1', 'serial': 'ser123', 'location': 3, 'distance': 2, 'loc': 3},
                 {'id': 12, 'model': 'm1', 'serial': 'ser456', 'location': 3, 'distance': 2, 'loc': 3},
                 {'id': 13, 'model': 'm2', 'serial': 'ser678', 'location': 5, 'distance': 2, 'loc': 5}]
    

throws:

    
    
    Traceback (most recent call last):
      File "job_manager.py", line 1, in <module>
        from NewJM import JobMonitor
      File "C:\Users\Jonathan\Documents\Coding\Python\Logistics Code\NewJM.py", line 56
    itemData2 = [{'id': 11, 'model': 'm1', 'serial': 'ser123', 'location': 3, 'distance': 2, 'loc': 3},
                                                                                                      ^
    IndentationError: unindent does not match any outer indentation level
    

second version of list two:

    
    
    itemData2 = [
        {'id': 11, 'model': 'm1', 'serial': 'ser123', 'location': 3, 'distance': 2, 'loc': 3},
        {'id': 12, 'model': 'm1', 'serial': 'ser456', 'location': 3, 'distance': 2, 'loc': 3},
        {'id': 13, 'model': 'm2', 'serial': 'ser678', 'location': 5, 'distance': 2, 'loc': 5}
    ]
    

throws:

    
    
    Traceback (most recent call last):
      File "job_manager.py", line 1, in <module>
        from NewJM import JobMonitor
      File "C:\Users\Jonathan\Documents\Coding\Python\Logistics Code\NewJM.py", line 56
    itemData2 = [
                ^
    IndentationError: unindent does not match any outer indentation level
    

I am confused as to why this is happening, especially since the first version
of list two is a direct copy of list one only with the addition of another
dict. Any ideas?


Answer: It's look like you have tabs with spaces mix in your code. Symple copy-paste
of your code from your question works correctly.

