Copyright © tutorialspoint.com

Python String center() Method

previous next


Description:

This method returns centered in a string of length width. Padding is done using the specified fillchar. Default filler is a space.

Syntax:

str.center(width[, fillchar])

Parameters:

Here is the detail of parameters:

Return Value:

It returns centered in a string of length width.

Example:

#!/usr/bin/python

str = "this is string example....wow!!!";

print "str.center(40, 'a') : ", str.center(40, 'a')

This will produce following result:

str.center(40, 'a') :  aaaathis is string example....wow!!!aaaa

previous next

Copyright © tutorialspoint.com