Use break to stop execution and break out of the current loop : Break : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Break »

 

Use break to stop execution and break out of the current loop


# Use continue to stop execution of the current iteration and start the next iteration of the current loop


word = "this is a test"
string = ""
for ch in word:
    if ch == 'i':
        string +='y'
        continue
    if ch == ' ':
        break
    string += ch
print string



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» Break