

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to concatenate a string with numbers in Python?
To concatenate a string with numbers, you need to cast the numbers to string using str(number). For example,
>>> a = "string" >>> b = 1 >>> print a + str(b) string1
In Python 2, you can also use backtick(``) to surround the number and get the same result with numbers and strings. Note that backticks have been removed from Python 3. For example,
>>> a = "string" >>> b = 1 >>> print a + `b` string1
- Related Questions & Answers
- Concatenate string with numbers in MySQL?
- How to concatenate string vectors separated with hyphen in R?
- How to concatenate variable in a string in jQuery?
- Concatenate null to a string in Java
- How to extract numbers from a string in Python?
- What is the preferred way to concatenate a string in Python?
- How to concatenate numerical vectors and a string to return a string in R?
- How to sum a comma separated string (string with numbers) in MySQL?
- How to concatenate multiple string variables in JavaScript?
- How to extract numbers from a string using Python?
- Java Program to Concatenate String.
- How to concatenate MySQL distinct query results into a string?
- How to concatenate a std::string and an int in C++?
- Java Program to concatenate a String and Integers
- Java Program to concatenate Integers and a String
Advertisements