# lecture_02_whitespace_errors_template.py # Oliver W. Layton # CS 151: Computational Thinking: Visual Media # Spring 2021 # Demonstrate common Python errors due to white space inconsistencies from turtle import * # Error 1: mixing tabs and spaces. # I used the tab key to intend all commands in this function except the last one. # I hit the spacebar (space) 4 times to intent the last line. # Tabs and spaces are both considered "whitespace". # Results in: IndentationError: unindent does not match any outer indentation level # # Fix 1: Manually delete one of the whitespace and change it to the other one. # Fix 2: In VS Code: click "Spaces:" on the bottom-right of VS Code, click on # Convert Indentation to Spaces. # VS Code then will convert all indented lines to spaces (as would be produced by # pressing spacebar)! # # I suggest using spaces to indent rather than tabs, but either work fine. # Pick one and stick with it! # def triangle(): # forward(100) # right(120) # forward(100) # right(120) # forward(100) # right(120) # triangle() # Error 2: Not intenting when you mean to # def triangle(): # forward(100) # right(120) # forward(100) # right(120) # forward(100) # triangle() exitonclick()