Python String zfill() method

The string.zfill() method in Python returns a copy of the string while adding the zeros (0) at the beginning of the string, until it reaches the specified width.

Syntax

Parameter

width – This parameter represents a number specifying the position of the element you want to remove.

Return

This method returns the numeric string left filled with zeros in a string of length width.

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This