Product SiteDocumentation Site

6.9. Continue പ്രസ്താവന

break പ്രസ്താവനയെപ്പോലെ ഉപയോഗിക്കാവുന്ന മറെറാരു പ്രസ്താവനയാണ് continue, ഇത് തനിക്കു ശേഷമുളള കോഡിന്‍റെ എക്സിക്യൂഷന്‍ ഒഴിവാക്കുകയും ലൂപ്പിന്‍റെ തുടക്കത്തിലേക്ക് തിരിച്ചുപോവുകയും ചെയ്യുന്നു.വിശദമായി പറഞ്ഞാല്‍ ഇത് ലൂപ്പിന്‍റെ ഒരു ഭാഗത്തെ ഒഴിവാക്കുന്നു.താഴെ കൊടുത്തിരിക്കുന്ന ഉദാഹരണത്തില്‍ നമ്മള്‍ യൂസറിനോട് ഒരു ഇന്‍പുട്ട് ചോദിക്കുകയും,കിട്ടിയ ഇന്‍പുട്ട് നെഗററീവാണെങ്കില്‍ വീണ്ടും ആവശ്യപ്പെടുകയും ചെയ്യുന്നു,വീണ്ടും കിട്ടിയ ഇന്‍പുട്ട് പോസിററീവ് ആണെങ്കില്‍ അതിന്‍റെ വര്‍ഗം കണ്ടുപിടിക്കുന്നു.യൂസര്‍ 0 ആണ് ഇന്‍പുട്ടായി നല്‍കിയിരിക്കുന്നതെങ്കില്‍ ലൂപ്പില്‍ നിന്ന് പുറത്തുകടക്കുകയും ചെയ്യുന്നു.

#!/usr/bin/env python
while True:
    n = int(raw_input("Please enter an Integer: "))
    if n < 0:
        continue #this will take the execution back to the starting of the loop
    elif n == 0:
        break
    print "Square is ", n ** 2
print "Goodbye"

ഔട്ട്പുട്ട്
[kd@kdlappy book]$ ./continue.py
Please enter an Integer: 34
Square is 1156
Please enter an Integer: 4
Square is 16
Please enter an Integer: -9
Please enter an Integer: 0
Goodbye