How to Print String and Int in the Same Line in Python Last Updated : 26 Sep, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report Printing both texts and integers on the same line is a common chore for programmers. Python, fortunately, has various methods for accomplishing this, making it simple to display a combination of text and numerical values in your output. In this article, we'll explore various ways to print strings and integers in the same line in Python. Print String and Int in the Same Line in PythonLet's see the different approaches to solve this problem: Using the ConcatenationUsing f-stringsUsing the format()Using the str.join()Print String and Int in the Same Line using ConcatenationIn this example, we combine the strings "My name is ", name, " and I am ", and the string representation of age using the + operator. Python3 name = "John" age = 30 print("My name is " + name + " and I am " + str(age) + " years old.") OutputMy name is John and I am 30 years old.Print String and Int in the Same Line using f-stringsYou can directly embed variables and expressions inside f-strings by placing them within curly braces {}. Here's how you can use f-strings to print strings and integers in the same line: Python3 name = "John" age = 30 print(f"My name is {name} and I am {age} years old.") OutputMy name is John and I am 30 years old.Print String and Int in the Same Line using format() MethodIn this code, we create a template string message with two placeholders {}. We then use the format() method to replace the placeholders with the values of name and age. Python3 name = "John" age = 30 message = "My name is {} and I am {} years old." formatted_message = message.format(name, age) print(formatted_message) OutputMy name is John and I am 30 years old.Print String and Int in the Same Line using str.join()In this code, we use the map() function to convert all elements in the data list to strings, and then we use the join() method to combine them with a space delimiter. Python3 name = "John" age = 30 print("My name is", name, "and I am", age, "years old.") OutputMy name is John and I am 30 years old. Comment More infoAdvertise with us Next Article How to convert string to integer in Python? A amitgupm1wy Follow Improve Article Tags : Python Geeks Premier League Geeks Premier League 2023 Practice Tags : python Similar Reads String to Int and Int to String in Python Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing the information about converting a string to int and int to string. Converting a string to an int If we want to convert a number that is represented in the string to int, we have 2 min read How to find the int value of a string in Python? In Python, we can represent an integer value in the form of string. Int value of a string can be obtained by using inbuilt function in python called as int(). Here we can pass string as argument to this function which returns int value of a string. int() Syntax : int(string, base) Parameters : strin 2 min read How to convert string to integer in Python? In Python, a string can be converted into an integer using the following methods : Method 1: Using built-in int() function: If your string contains a decimal integer and you wish to convert it into an int, in that case, pass your string to int() function and it will convert your string into an equiv 3 min read Convert Strings to Numbers and Numbers to Strings in Python Converting strings to numbers and numbers to strings is a common task in Python. In this article, weâll explore simple ways to convert between strings and numbers .Using int() and str()int() and str() functions in Python are commonly used for converting data types. The int() function changes a strin 3 min read How to print spaces in Python3? In this article, we will learn about how to print space or multiple spaces in the Python programming language. Spacing in Python language is quite simple than other programming language. In C languages, to print 10 spaces a loop is used while in python no loop is used to print number of spaces. Foll 2 min read Convert String to Int in Python In Python, converting a string to an integer is important for performing mathematical operations, processing user input and efficiently handling data. This article will explore different ways to perform this conversion, including error handling and other method to validate input string during conver 3 min read Like