Center Method
Center Method
Note : Center method is generally used to center align the string using specified character.
user_name = "xtra"
print(user_name.center(6, "#"))
Output: #xtra#
user_name = "xtra"
print(user_name.center(5, "#"))
Output: #xtra
user_name = "xtra"
print(user_name.center(6, "s"))
Output: sxtras
user_name = "hello"
print(user_name.center(6, "#"))
Output: hello#
Post a Comment