Python Forum
Find index of missing number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find index of missing number
#1
Find missing number position / index based on the input

Here is the sample data.

def missing_numbers(num_list):
      original_list = [x for x in range(num_list[0], num_list[-1] + 1)]
      num_list = set(num_list)
      return (list(num_list ^ set(original_list)))

missing_numbers([1,2,3,4,6,7,10])
[5, 8, 9]
>>>
it returns 5 ,8,9, but how to say that the it is missing in the index of 4,7,8.

Output 1,2,3,4,5,6,7,8,9,10
Index 0,1,2,3,4,5,6,7,8,9
Reply


Messages In This Thread
Find index of missing number - by parthi1705 - May-07-2019, 04:26 AM
RE: Find index of missing number - by perfringo - May-07-2019, 06:09 AM
RE: Find index of missing number - by parthi1705 - May-07-2019, 07:30 AM
RE: Find index of missing number - by avorane - May-07-2019, 10:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  find the sum of a series of values that equal a number ancorte 1 573 Oct-30-2023, 05:41 AM
Last Post: Gribouillis
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,542 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Find if chain of characters or number Frankduc 4 1,878 Feb-11-2022, 01:55 PM
Last Post: Frankduc
Question Help to find the largest int number in a file directory SalzmannNicholas 1 1,714 Jan-13-2022, 05:22 PM
Last Post: ndc85430
  labels.append(self.classes.index(member.find('name').text)) hobbyist 1 1,987 Dec-15-2021, 01:53 PM
Last Post: deanhystad
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,452 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Regular expression: cannot find 1st number in a string Pavel_47 2 2,486 Jan-15-2021, 04:39 PM
Last Post: bowlofred
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,817 Aug-25-2020, 01:52 AM
Last Post: tester_V
  str.find() not returning correct index. DreamingInsanity 10 4,479 Aug-18-2020, 05:41 PM
Last Post: DreamingInsanity
  Find index value in List Martin2998 3 2,899 May-12-2020, 02:17 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020