from datetime import datetime as dt class Employee: def __init__(self, first, last, date_of_birth): console.warn(f"__init__('{first}', '{last}', {date_of_birth})") if not first: raise ValueError('Missing first name') if not last: raise ValueError('Missing last name') if not date_of_birth: raise ValueError('Missing date of birth') self.first = first self.last = last try: self.date_of_birth = dt.strptime(date_of_birth, '%Y-%m-%d').date() except: raise ValueError(f"Invalid date of birth '{date_of_birth}'") def __str__(self): console.warn(f"__str__({self.first} {self.last}, {self.date_of_birth:%Y-%m-%d})") return f"Full Name: {self.first} {self.last}, Date of birth: {self.date_of_birth:%Y-%m-%d}" def printf(self, id): console.warn(f"printf('{id}')") match id: case 'JP': return f"Full Name: πŸ—Ύ {self.last} {self.first}, Date of birth: {self.date_of_birth:%Y/%m/%d}" case 'US': return f"Full Name: πŸ‡ΊπŸ‡Έ {self.first} {self.last}, Date of birth: {self.date_of_birth:%m-%d-%Y} ({self.date_of_birth:%B %d, %Y})" case 'GB': return f"Full Name: πŸ‡¬πŸ‡§ {self.first} {self.last}, Date of birth: {self.date_of_birth:%d-%m-%Y} ({self.date_of_birth:%d %B %Y})" case 'ISO': return f"Full Name: ISO {self.first} {self.last}, Date of birth: {self.date_of_birth:%Y-%m-%d}" case _: return f"Full Name: πŸ˜„ {self.first} {self.last}, Date of birth: {self.date_of_birth:%Y-%m-%d}" def get_employee(): console.warn('get_employee()') first = input(); print(f"First name: {first}") last = input(); print(f"Last name: {last}") date_of_birth = input() # yyyy-mm-dd print(f"Date of birth: {date_of_birth}") return Employee(first, last, date_of_birth) # return class employee = get_employee() # get class print(employee.printf('US'))