>>> for i in [1, 2, 3]: ... print i ... continue ... print 'test' 1 2 3
This does demonstrate what
continue does, but you would never write something like this in real code. You would just leave out
print "test" entirely. It seems like this example might be counter-productive.
Another type of example that I have seen elsewhere that I think might be counter-productive is indexing into string literals. For example, in some languages you can write the following:
which would evaluate to
"H" but if you actually wanted an expression that evaluated to
"H", you would just use
Does it make sense to use contrived examples like this, or is it likely to introduce confusion in students?