In: Computer Science
Creating a list/tuple
3.Given a list of tuples containing student first names and last names e.g. (“John”, “Doe”) that represents a class. Ask the user for a students first and last name and check if that student is a member of the class.
Program Code Screenshot :
Sample Output :
Program Code to Copy (Please refer to the screenshot of the code to understand the indentation of the code)
#Given students list
c = [('John','Doe')]
#Prompt for first and last names
first = input('Enter the first name: ')
last = input('Enter the last name: ')
#Check if (first,last) is in the list of students
if (first,last) in c:
print('Student is a member of the class')
else:
print('Student is not a member of the class')