Answer to Question #296610 in Python for Sudheer

Question #296610

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

1
Expert's answer
2022-02-11T12:12:46-0500
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)






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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS