thanks very much for the detailed explanation (it helped me understand the code a lot!)
just one problem which is probably just a stupid thing I am doing wrong
when I run the code in either python 2 or 3 it says that there is ivalid syntax with the = in this part
if pattern = 1:
I also assume it is happening with the second one but it only displays one error at a time.
what am i doing wrong
Thank you