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
Step: 1
python def longestrunlist1 count 1 Initialize count to 1 maxcount 1 Initialize maxcount to ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Business Analytics Methods Models And Decisions
Authors: James R. Evans
2nd Edition
321997824, 978-1119298588, 978-0321997821
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App