String Formatting with Dictionary

  • Share this:

Code introduction


This function takes an input string and a formatting dictionary, and uses Python's str.format() method to format the string.


Technology Stack : String formatting

Code Type : String formatting

Code Difficulty : Intermediate


                
                    
def format_string(input_string, new_format):
    return input_string.format(**new_format)