zfill in python

Description

The method zfill() pads string on the left with zeros to fill width.

Syntax

Following is the syntax for zfill() method

Parameters

width — This is final width of the string. This is the width which we would get after filling zeros.

eg;

str = “happy new year”

print str.zfill(40)

print str.zfill(15)

Output:

00000000000000000000000000happy new year
0happy new year