Skip to content

Instantly share code, notes, and snippets.

@edenau
Created February 2, 2020 23:25
Show Gist options
  • Save edenau/508e647c8d93f9c42923e8d747548501 to your computer and use it in GitHub Desktop.
Save edenau/508e647c8d93f9c42923e8d747548501 to your computer and use it in GitHub Desktop.
def test(nums):
for i in nums:
if i == 0: # if the condition is satisfied, it hits break and the else block will not run
print('There is a 0.')
break
else:
print('There are no 0s.')
test([1,2,3,0]) # There is a 0.
test([1,2,3]) # There are no 0s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment