W3docs

How can I print variable and string on same line in Python?

You can use the print() function in Python and use the + operator to concatenate a string and a variable.

You can use the print() function in Python and use the + operator to concatenate a string and a variable. For example:

Concatenate a string and a variable in Python using the + operator

python— editable, runs on the server
Info

Watch a video course: Python - The Practical Guide

Alternatively, you can use the format() method to insert the value of a variable into a string, like this:

Concatenate a string and a variable in Python using the format method

python— editable, runs on the server

or use f-strings (Python 3.6+)

Concatenate a string and a variable in Python using the f-strings

python— editable, runs on the server

You can put all these examples in the same program and will run successfully.