write a python function Check_RollNo(A, n) (Refer RollNo_W8B_3.py ) which take a list A and nth roll number as input and return first nth roll number and Second roll number from the nth last roll number as shown in example. If nth roll number is not lies in the range of list, then function will return "n is not in range" in place of first roll number and empty string (“”) in place of second roll number
def rollNums(numbers, n):
if n > len(numbers) or n < 1:
return "n is not in range",""
else:
return numbers[n-1], numbers[-n]
numbers =[int(x) for x in input("Enter numbers: ").split(', ')]
n=int(input("Ente n: "))
firstNthRollNumber,secondRollNumber =rollNums(numbers, n)
print(firstNthRollNumber)
print(secondRollNumber)
Comments
Leave a comment