Sharing is caring!

In this code, the user (student) will be asked to enter his information only once ( for each student). Finally, make the name ‘exit’ to complete this process.

students = []
while True:
    name = input("Enter student name (or 'exit' to finish): ")
    if name.lower() == 'exit':
    age = input("Enter student age: ")
    gender = input("Enter student gender: ")
    student = {'name': name, 'age': age, 'gender': gender}

print("\nStudent Details:")
for student in students:
    print("Name:", student['name'])
    print("Age:", student['age'])
    print("Gender:", student['gender'])

As a result, the program prints out the information for all of the students who have been entered.

Categories: Python

1 Comment

Utwórz konto na Binance · April 12, 2024 at 10:28 pm

Your article helped me a lot, is there any more related content? Thanks!

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *