I'm finding max value and min value of a list by using max(list)
and min(list)
in Python. However, I wonder how to manage empty lists.
For example if the list is an empty list []
, the program raises 'ValueError: min() arg is an empty sequence'
but I would like to know how to make the program just print 'empty list or invalid input'
instead of just crashing. How to manage those errors?