Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a function to count the longest consecutive numbers in list. for example, if the list1 is [1, 3, 4, 5, 6] the longest

Make a function to count the longest consecutive numbers in list.

 

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

Step: 1

python def longestrunlist1 count 1 Initialize count to 1 maxcount 1 Initialize maxcount to ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Analytics Methods Models And Decisions

Authors: James R. Evans

2nd Edition

321997824, 978-1119298588, 978-0321997821

More Books

Students also viewed these Programming questions