Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if True:
- if False:
- print('foo')
- print('bar')
- File "script.py", line 4
- print('bar')
- ^
- IndentationError: unindent does not match any outer indentation level
- def perm(l):
- # Compute the list of all permutations of l
- if len(l) <= 1:
- return [l]
- r = []
- for i in range(len(l)):
- s = l[:i] + l[i+1:]
- p = perm(s)
- for x in p:
- r.append(l[i:i+1] + x)
- return r
- def perm(l):
- # Compute the list of all permutations of l
- if len(l) <= 1:
- return [l]
- r = []
- for i in range(len(l)):
- s = l[:i] + l[i+1:]
- p = perm(s)
- for x in p:
- r.append(l[i:i+1] + x)
- return r
- >>> print('Hello') # this is indented
- File "<stdin>", line 1
- print('Hello') # this is indented
- ^
- IndentationError: unexpected indent
- >>> age = 10
- >>> can_drive = None
- >>>
- >>> if age >= 18:
- ... print('You can drive')
- ... can_drive = True # incorrectly indented
- File "<stdin>", line 3
- can_drive = True # incorrectly indented
- ^
- IndentationError: unexpected indent
- >>> print('Hello') # simply unindent the line
- Hello
- >>> age = 10
- >>> can_drive = None
- >>>
- >>> if age >= 18:
- ... print('You can drive')
- ... can_drive = True # indent this line at the same level.
- ...
- >>> if True:
- ...
- File "<stdin>", line 2
- ^
- IndentationError: expected an indented block
- >>> names = ['sarah', 'lucy', 'michael']
- >>> for name in names:
- ... print(name)
- File "<stdin>", line 2
- print(name)
- ^
- IndentationError: expected an indented block
- >>> if True:
- ... # TODO
- ...
- File "<stdin>", line 3
- ^
- IndentationError: expected an indented block
- >>> names = ['sarah', 'lucy', 'michael']
- >>> for name in names:
- ... print(name) # The for loop body is now correctly indented.
- ...
- sarah
- lucy
- michael
- def f(arg): pass # a function that does nothing (yet)
- class C: pass # a class with no methods (yet)
- >>> if True:
- ... pass # We don't want to define a body.
- ...
- >>>
- >>> if True:
- ... if True:
- ... print('yes')
- ... print()
- File "<stdin>", line 4
- print()
- ^
- IndentationError: unindent does not match any outer indentation level
- >>> if True:
- ... if True:
- ... print('yes')
- ... print() # indentation level now matches former statement's level.
- ...
- yes
- >>>
- >>> if True:
- ... if True:
- ... print()
- ... print()
- ... print()
- File "<stdin>", line 5
- print()
- ^
- TabError: inconsistent use of tabs and spaces in indentation
- >>> if True:
- ... if True: # tab
- ... pass # tab, then 4 spaces
- ...
- >>>
- >>> if True:
- ... pass # tab
- ... pass # 4 spaces
- File "<stdin>", line 3
- pass # 4 spaces
- ^
- IndentationError: unindent does not match any outer indentation level
- if True:
- pass
- pass # oops! this statement should be indented!.
- else:
- pass
- Traceback (most recent call last):
- File "python", line 4
- else:
- ^
- SyntaxError: invalid syntax
- if True:
- if False:
- print('foo')
- print('bar')
- if True:
- if False:
- print('foo')
- print('bar')
Add Comment
Please, Sign In to add comment