Python Concatenation and Formatting

Most used concatenation and formatting in python 3.x.
For reference, the ‘>>>’ characters indicate where the interpreter is requesting a command.

Photo by Shahadat Rahman on Unsplash


In string concatetion, we can use ‘+’ or comma separator

In string and other datatype (int), can not directly use ‘+’ to concate and print

try to convert int to str, or use comma separated.

Formatting with %

%s indicate the datatype is string

%i indicate the datatype is int

%.2f indicate the datatype is with 2 digits after dot

Formatting with Curve Bracket {}



Software Engineer, Indonesia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store