Python format() function

The format() function in Python formats a specified value into the given format. A ‘TypeErrorexception’ is raised if the method search reaches the object and the format_spec is non-empty, or if either the format_spec or the return value is not strings.

Syntax

Parameter

value: This parameter represents a value of any format

format_spec :The format_specs parameter represents the format.

Return

This function returns the value in the specified format.

Example 1

Output

 

Pin It on Pinterest

Share This