Home

Published

- 1 min read

stop a function from continuing when a condition is met python

img of stop a function from continuing when a condition is met python

The solution for this is noted below

stop a function from continuing when a condition is met python

Solution

   # use return e.g
def test_function(input):
  if input == 5:
    return
  else:
    print(input)

#f you run
test_function(5)
#the function will simply just end

Try other methods by searching on the site. That is if this doesn’t work