Advertisement
jacknpoe

Break, continue e pass em Python

Feb 7th, 2024
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | Source Code | 0 0
  1. # break
  2. def exemplo_break(numero):
  3.     for temp in range(1,numero):
  4.         if temp == 5:
  5.             break
  6.         print(temp)
  7.  
  8.  
  9. # continue
  10. def exemplo_continue(numero):
  11.     for temp in range(1,numero):
  12.         if temp == 5:
  13.             continue
  14.         print(temp)
  15.  
  16.  
  17. #pass
  18. def exemplo_pass(numero):
  19.     for temp in range(1,numero):
  20.         if temp % 2:
  21.             pass
  22.         else:
  23.             print(temp)
  24.  
  25.  
  26. # Main
  27. if __name__ == '__main__':
  28.     exemplo_break(10)
  29.     exemplo_continue(10)
  30.     exemplo_pass(10)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement