Advertisement
go6odn28

students._4

Mar 4th, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. students_info = []
  2. searched_course = ""
  3.  
  4. while True:
  5.     info = input()
  6.     if ":" not in info:
  7.         searched_course = info
  8.         break
  9.  
  10.     data = info.split(":")
  11.     name, id_, course = data[0], int(data[1]), data[2]
  12.     students_info.append({"name": name, "id": id_, "course": course})
  13.  
  14. for student in students_info:
  15.     if searched_course.startswith(student["course"][0:2]):
  16.         print(f"{student['name']} - {student['id']}")
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement