Advertisement
mbratanov

03. SoftUni Students

Oct 20th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def softuni_students(*args, **kwargs):
  2.     result = []
  3.     invalid_courses = []
  4.     for course_id, username in sorted(args, key=lambda item: item[1]):
  5.         if course_id in kwargs:
  6.             course = kwargs[course_id]
  7.             result.append(f"*** A student with the username {username} has successfully finished the course {course}!")
  8.         else:
  9.             invalid_courses.append(username)
  10.     if invalid_courses:
  11.         result.append(f"!!! Invalid course students: {', '.join(sorted(invalid_courses))}")
  12.     return "\n".join(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement