Question: Make a function to count the longest consecutive numbers in list. for example, if the list1 is [1, 3, 4, 5, 6] the longest
for example, if the list1 is [1, 3, 4, 5, 6]
the longest consecutive numbers are [4, 5, 6]
and the length of the numbers is 3
so the answers should be 3
the numbers in the list1 can increase or decrease.
The format should be like
def longest_run(list1)
...(statement)
...
...
return largest_length
if there is no consecutive number, it should return '1'
Step by Step Solution
3.31 Rating (145 Votes )
There are 3 Steps involved in it
python def longestrunlist1 count 1 Initialize count to 1 maxcount 1 Initialize maxcount to ... View full answer
Get step-by-step solutions from verified subject matter experts
