Catch and handle the exception.
try:
print(min(l), max(l))
except (ValueError, TypeError):
print('empty list or invalid input')
ValueError
is raised with an empty sequence. TypeError
is raised when the sequence contains unorderable types.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…