""" 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)
Comments
Leave a comment