How do I concatenate two integer numbers in Python? For example, given 10
and 20
, I'd like a returned value of "1020"
.
Python supports string concatenation using + operator. In most of the programming languages, if we concatenate a string with an integer or any other primitive data types, the language takes care of converting them to string and then concatenate it.
The extend method() adds all the elements of the list till the end. To concatenate the list on integers “+” is used. The print(newlist) is used to get the output.
This means that you can no longer perform any math operations on them. To combine numbers, use the CONCATENATE or CONCAT, TEXT or TEXTJOIN functions, and the ampersand (&) operator. Notes: In Excel 2016, Excel Mobile, and Excel for the web, CONCATENATE has been replaced with the CONCAT function.
Cast both to a string, concatenate the strings and then cast the result back to an integer:
z = int(str(x) + str(y))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With