Understanding functions and test cases!
Can copy/paste code into this URL to try it out: https://reeborg.ca/reeborg.html?lang=en&mode=python&menu=worlds%2Fmenus%2Freeborg_intro_en.json&name=Maze&url=worlds%2Ftutorial_en%2Fmaze1.json Focuses: - Defining and using functions - While loops - PEP8 Indentation styles (4 spaces) - Spaces vs. Tabs
This commit is contained in:
parent
da15b8f461
commit
88ad0f92ce
1 changed files with 17 additions and 0 deletions
17
Day 6/reeborg-maze.py
Normal file
17
Day 6/reeborg-maze.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
def turn_right():
|
||||
turn_left()
|
||||
turn_left()
|
||||
turn_left()
|
||||
|
||||
while front_is_clear():
|
||||
move()
|
||||
turn_left()
|
||||
|
||||
while not at_goal():
|
||||
if right_is_clear():
|
||||
turn_right()
|
||||
move()
|
||||
elif front_is_clear():
|
||||
move()
|
||||
else:
|
||||
turn_left()
|
||||
Loading…
Add table
Add a link
Reference in a new issue