Pairing Characters of Strings

  • Share this:

Code introduction


This function pairs the corresponding characters of two strings, arg1 and arg2, and returns them as a dictionary. If the inputs are not two strings, it returns None.


Technology Stack : Data structure, string manipulation, dictionary

Code Type : Data structure

Code Difficulty : Intermediate


                
                    
def azip(arg1, arg2):
    if isinstance(arg1, str) and isinstance(arg2, str):
        return {char: (arg1, arg2) for char in zip(arg1, arg2)}
    return None