Pay special attention to the section on Intersection and Turn Handling starting on slide 26
To make a variable a list, assign a value to it inside of square brackets
listvar = []
To add a new value to a list use the append method
listvar.append("L")
To remove items from the list use the pop method
listvar.pop() # Remove the last element listvar.pop(0) # Remove the first element listvar.pop(1) # Remove the second element listvar.pop(-1) # Remove the last element listvar.pop(-2) # Remove the second from last element
To access the value of a particular item in the list place the index of the item in square brackets. The index of the first item is '0'. Negative numbers start at the end of the list.
myval = listvar[3] # Retrieve the 4th element myval = listvar[1] # Retrieve the 2nd element lastval = listvar[-1] # Retrieve the last element almostlastval = listvar[-2] # Retrieve the 2nd to last element
A variable can also be used as the index. In that case the value of the variable must be a number and will be used to determine the index for the value that is returned from the list.
ivar = 3 ivar2 = ivar + 3 myval = listvar[ivar] # Retrieve the 4th element myval2 = listvar[ivar2] # Retrieve the 7th element
The sys module will need to be imported to get parameters from the command line. The argparse module is helpful to make defining and getting parameters easier. Google is your friend to figure out how to implement this
Not only will the decisions be in reverse order, the turns will also be backwards.
Great embarassment will be yours if it performs its “Happy Dance” before reaching the end of the maze