IndentationError: unindent does not match any outer indentation level

后端 未结 30 2019
Happy的楠姐
Happy的楠姐 2020-11-21 07:48

When I compile the Python code below, I get

IndentationError: unindent does not match any outer indentation level




        
30条回答
  •  野性不改
    2020-11-21 08:34

    For example:

    1. def convert_distance(miles):
    2.   km = miles * 1.6
    3.   return km
    

    In this code same situation occurred for me. Just delete the previous indent spaces of line 2 and 3, and then either use tab or space. Never use both. Give proper indentation while writing code in python. For Spyder goto Source > Fix Indentation. Same goes to VC Code and sublime text or any other editor. Fix the indentation.

提交回复
热议问题