On Tue, 18 May 2010 10:34:16 pm M. Bashir Al-Noimi wrote:
> Hi All,
>
>
> I couldn't understand the difference between pass and continue
> keywords, could you explain to me?


"pass" is a do-nothing statement. It literally does nothing.

"continue" is only allowed inside a for-loop or while-loop, and 
means "jump to the start of the loop". It is related to "break".

Consider the difference between these three loops:


>>> for x in (1,2,3):
...     print(x)
...     pass
...     print(x, "again")
...
1
1 again
2
2 again
3
3 again
>>>
>>>
>>> for x in (1,2,3):
...     print(x)
...     continue
...     print(x, "again")
...
1
2
3
>>>
>>>
>>> for x in (1,2,3):
...     print(x)
...     break
...     print(x, "again")
...
1
>>>



-- 
Steven D'Aprano
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to