ZFILL IN PYTHON

The zfill() method adds zeros (0) at the beginning of the string, until it reaches the specific length.

If the value of the len parameter is less than the length of the string, no filling is done.

Syntax:

string.zfill(len)

parameter: len

A number specifying the position of the element you want to remove.

EXAMPLES:

a=”hello”

print(a.zfill(10))

Output: >> 00000hello

b=”Welcome to the jungle”

print(b.zfill(10))

Output: >> Welcome to the jungle

Leave a comment

Design a site like this with WordPress.com
Get started