I'm a newbie in python & using python 3.4.3 in PyCharm in windows. Suppose that i have a list in python in which (0,2,4)th elements are names(string) and (1,3,5)th elements are theirs' rolls(int)
list = ['a',12,'b',16,'c',20]
if i want to prompt the user to enter a roll number, then delete the roll and the previous string with:
delRoll = list.index(int(input("Delete roll no: ")))
del (list[delRoll - 1: delRoll + 1])
i tested it worked fine(e.g.deleted the name and roll) if the user enters the numbers enlisted in the list
, But how to find if the users hasn't entered a roll that is not enlisted in the list
& give him/her a error message?