Day 28: RegEx, Patterns, and Intro to Databases

  • + 0 comments
    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    from typing import List
    
    def print_gmail(first_names: List[str], emails: List[str]):
        paired = dict(zip(emails, first_names))
        filtered = dict(filter(lambda data: "@gmail.com" in data[0], paired.items()))
        ordered_name = []
        ordered_email = []
        for name in filtered.values():
            ordered_name.append(name)
        ordered_name.sort()
        for name in ordered_name:
            print(name)
    
    
    if __name__ == '__main__':
        N = int(input().strip())
        
        names = []
        emails = []
        
        for N_itr in range(N):
            first_multiple_input = input().rstrip().split()
    
            firstName = first_multiple_input[0]
            names.append(firstName)
    
            emailID = first_multiple_input[1]
            emails.append(emailID)
        print_gmail(names, emails)