In this tutorial, we will learn to format the output. Formatting and output refer to presenting the output of a program.
There are various ways to format output.
- We can use the f string method to format the string literals.
- The format() method of strings helps a user create a fancier output.
- We can also perform the string concatenation operations to create any layout we want. The string class also has some methods that perform useful operations for padding strings to given column width.
Figure 1
mail = "basahin@hotmail.com"
lastName = "Sahin"
id=1
firstName="Bahadir"
text = "Person: {0}, {1}, {2}, {3}"
print(text.format(id,firstName,lastName,mail))
Hope to see you in the next article. Happy coding
No comments:
Post a Comment