The line q = [start] means create a variable called q, and assign the value [start] to it. In this case, it will create a list with one element: the value of the variable start. It's the exact same syntax as q = [1, 2], but it uses a variable instead of a constant value.
After this, the line while q: is a use (or abuse) of Python's type conversion system. While loops require a boolean condition to know whether they should repeat, so your code is equivalent to while bool(q):. To understand how this works, let's examine the possible cases:
bool([1]) == True # This applies for any non-empty list
bool([]) == False # This applies to any empty list
Therefore, the meaning of while q: is actually 'while q is non-empty'.
q = [start]means 'make a list calledq, and put the variablestartin as the first element'.while q:means 'repeat the following indented block until it is empty' (because lists coerce to booleanTruewhile non-empty andFalsewhile empty). Is the indentation as you are showing here though? If so, it won't run correctly.