Guest User

Untitled

a guest
Jul 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. if True:
  2. if False:
  3. print('foo')
  4. print('bar')
  5.  
  6. File "script.py", line 4
  7. print('bar')
  8. ^
  9. IndentationError: unindent does not match any outer indentation level
  10.  
  11. def perm(l):
  12. # Compute the list of all permutations of l
  13. if len(l) <= 1:
  14. return [l]
  15. r = []
  16. for i in range(len(l)):
  17. s = l[:i] + l[i+1:]
  18. p = perm(s)
  19. for x in p:
  20. r.append(l[i:i+1] + x)
  21. return r
  22.  
  23. def perm(l):
  24. # Compute the list of all permutations of l
  25. if len(l) <= 1:
  26. return [l]
  27. r = []
  28. for i in range(len(l)):
  29. s = l[:i] + l[i+1:]
  30. p = perm(s)
  31. for x in p:
  32. r.append(l[i:i+1] + x)
  33. return r
  34.  
  35. >>> print('Hello') # this is indented
  36. File "<stdin>", line 1
  37. print('Hello') # this is indented
  38. ^
  39. IndentationError: unexpected indent
  40.  
  41. >>> age = 10
  42. >>> can_drive = None
  43. >>>
  44. >>> if age >= 18:
  45. ... print('You can drive')
  46. ... can_drive = True # incorrectly indented
  47. File "<stdin>", line 3
  48. can_drive = True # incorrectly indented
  49. ^
  50. IndentationError: unexpected indent
  51.  
  52. >>> print('Hello') # simply unindent the line
  53. Hello
  54.  
  55. >>> age = 10
  56. >>> can_drive = None
  57. >>>
  58. >>> if age >= 18:
  59. ... print('You can drive')
  60. ... can_drive = True # indent this line at the same level.
  61. ...
  62.  
  63. >>> if True:
  64. ...
  65. File "<stdin>", line 2
  66.  
  67. ^
  68. IndentationError: expected an indented block
  69.  
  70. >>> names = ['sarah', 'lucy', 'michael']
  71. >>> for name in names:
  72. ... print(name)
  73. File "<stdin>", line 2
  74. print(name)
  75. ^
  76. IndentationError: expected an indented block
  77.  
  78. >>> if True:
  79. ... # TODO
  80. ...
  81. File "<stdin>", line 3
  82.  
  83. ^
  84. IndentationError: expected an indented block
  85.  
  86. >>> names = ['sarah', 'lucy', 'michael']
  87. >>> for name in names:
  88. ... print(name) # The for loop body is now correctly indented.
  89. ...
  90. sarah
  91. lucy
  92. michael
  93.  
  94. def f(arg): pass # a function that does nothing (yet)
  95.  
  96. class C: pass # a class with no methods (yet)
  97.  
  98. >>> if True:
  99. ... pass # We don't want to define a body.
  100. ...
  101. >>>
  102.  
  103. >>> if True:
  104. ... if True:
  105. ... print('yes')
  106. ... print()
  107. File "<stdin>", line 4
  108. print()
  109. ^
  110. IndentationError: unindent does not match any outer indentation level
  111.  
  112. >>> if True:
  113. ... if True:
  114. ... print('yes')
  115. ... print() # indentation level now matches former statement's level.
  116. ...
  117. yes
  118.  
  119. >>>
  120.  
  121. >>> if True:
  122. ... if True:
  123. ... print()
  124. ... print()
  125. ... print()
  126. File "<stdin>", line 5
  127. print()
  128. ^
  129. TabError: inconsistent use of tabs and spaces in indentation
  130.  
  131. >>> if True:
  132. ... if True: # tab
  133. ... pass # tab, then 4 spaces
  134. ...
  135. >>>
  136.  
  137. >>> if True:
  138. ... pass # tab
  139. ... pass # 4 spaces
  140. File "<stdin>", line 3
  141. pass # 4 spaces
  142. ^
  143. IndentationError: unindent does not match any outer indentation level
  144.  
  145. if True:
  146. pass
  147. pass # oops! this statement should be indented!.
  148. else:
  149. pass
  150.  
  151. Traceback (most recent call last):
  152. File "python", line 4
  153. else:
  154. ^
  155. SyntaxError: invalid syntax
  156.  
  157. if True:
  158. if False:
  159. print('foo')
  160. print('bar')
  161.  
  162. if True:
  163. if False:
  164. print('foo')
  165. print('bar')
Add Comment
Please, Sign In to add comment