Ask user to input a student name and subject, and display the corresponding mark data = { "Ali": {"Math": 85, "Science": 90}, "Sara": {"Math": 78, "Science": 88} }
data = { "Ali": {"Math": 85, "Science": 90}, "Sara": {"Math": 78, "Science": 88} }
Code:
data = {
"Ali": {"Math": 85, "Science": 90},
"Sara": {"Math": 78, "Science": 88}
}
student_name = input("Enter the student's name: ")
subject_name = input("Enter the subject: ")
if student_name in data:
if subject_name in data[student_name]:
print(f"{student_name}'s mark in {subject_name} is {data[student_name][subject_name]}")
else:
print(f"Subject '{subject_name}' not found for {student_name}.")
else:
print(f"Student '{student_name}' not found.")