Write a program in Python that accepts students names in the form of a tuple as an input from the user and then displays only those students' names that start with letter 'S' or 's'.
# Accept student names from the user
names = eval(input("Enter a tuple of student names: "))
print("Students whose names start with 'S' or 's':")
for name in names:
if name.startswith('S') or name.startswith('s'):
print(name)
Output:
Enter a tuple of student names: ('Amit','Sumit','Rohit','Sonu')
Students whose names start with 'S' or 's':
Sumit
Sonu
No comments:
Post a Comment