You can use the min
and max
functions
set1 = {1, 2, 3, 5}
set2 = {9, 8, 7, 10, 11, 12}
x1 = len(set1) == max(set1)-min(set1)+1 # False
x2 = len(set2) == max(set2)-min(set2)+1 # True
0
solved How do I write a function to check if a set is continuous? [closed]