Question #242647

Give a list of numbers write a program to print the smallest postive integer missing in the give numbers

Expert's answer

""" Program to print the smallest positive integer missing in a given list of numbers.
"""

print('Sample Input:')
# String containing list of numbers
numbers = "3 4 7 2 9 5 1"
print(numbers)
# List containing numbers in string form
numberListStr = numbers.split(' ')
# Convert each item in list to integer
numberListInt = [int(number) for number in numberListStr]

smallestMissing = 1

while True:
    if smallestMissing not in numberListInt:
        # Smallest missing number has been found
        break
    smallestMissing += 1

print()
print('Sample Output:')
print(smallestMissing)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS