Reputation:
I know basically nothing about python
(I did know about it before but never took the time to try it out). I've started using python
because I'm doing an A level course in computer science.
I wanted to know how to center align the output ?
What I've done to "center" align is:
print ("------(<< the spaces didnt show up in post, so i used "-"'s)How long have you been alive")
But I feel that its the wrong technique to use, how do I do it properly? Also, is it possible to change the colours of the output/runned view for example have a title black and other writing blue, and the background yellow.
Upvotes: 0
Views: 46
Reputation: 508
The method center() 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])
You could refer to the links below.
http://www.tutorialspoint.com/python/string_center.htm
https://docs.python.org/2/library/string.html#string.center
Upvotes: 1