how to kill a script if error is hit python

Solutions on MaxInterview for how to kill a script if error is hit python by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to kill a script if error is hit python"
Aarushi
27 May 2020
1import sys
2
3try:
4  print("stuff")
5except:
6  sys.exit(1) # exiing with a non zero value is better for returning from an error
7
similar questions