0

I have a list of numbers like

example list = [ 1,2,3,5,10,11] 

I want to split the list based on sequence

list1 = [1,2,3] list2 = [5] list3 = [10,11] 

But I am confused how to bring this to the code can anyone please help me regarding this, Thanks.

5
  • Your example makes no sense, are you sure list2 should be in that output? Are you looking to create multiple lists where the numbers are in sequence from the first list? Commented May 10, 2022 at 9:34
  • You haven't provided any rules. To make a guess, you mean that you want to break it into sets of numbers where the difference between them is 1? Why does list2 exist? Perhaps there's a different rule? Commented May 10, 2022 at 9:34
  • @DiplomacyNotWar Yes Exactly Commented May 10, 2022 at 9:36
  • This has been asked many times before, I've linked a few. Please search a bit harder next time :) Commented May 10, 2022 at 9:36
  • @DavidG Sorry for the wrong input I have corrected it now. Commented May 10, 2022 at 9:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.