93.5k views
2 votes
Create a function that takes a list of numbers between 1 and 10 (excluding one number)

and returns the missing number.

● Step 1:​ Create a function ​missing_num() and pass ​lst as a parameter inside this

function, where ​lst is the list of numbers from ​1 - 10 with one missing number.

● Step 2​: Run a ​for loop in range ​1 - 11 i.e. from 1 to 10. Inside the ​for loop, check

whether the number ​n is present in the list using an ​if condition.

● Step 3​: Inside the ​for loop, check whether each number is present in the list ​lst

using an ​if condition and ​in and ​not in operator. If the number is not present in the

list ​lst[], then print that number in the output.​

User Erlinda
by
5.2k points

1 Answer

5 votes

def missing_num(lst):

for n in range(1,11):

if n not in lst:

print(n)

lst = (1,3,4,5,6,7,8,9,10)

missing_num(lst)

I hope this helps!

User Mgus
by
4.7k points