How to concatenate two integers in Python?

Cast both to a string, concatenate the strings and then cast the result back to an integer:

z = int(str(x) + str(y))

Using math is probably faster than solutions that convert to str and back:

If you can assume a two digit second number:

def f(x, y):
    return x*100+y

Usage:

>>> f(1,2)
102
>>> f(10,20)
1020

Although, you probably would want some checks included to verify the second number is not more than two digits. Or, if your second number can be any number of digits, you could do something like this:

import math
def f(x, y):
    if y != 0:
        a = math.floor(math.log10(y))
    else:
        a = -1

    return int(x*10**(1+a)+y)

Usage:

>>> f(10,20)
1020
>>> f(99,193)
99193

This version however, does not allow you to merge numbers like 03 and 02 to get 0302. For that you would need to either add arguments to specify the number of digits in each integer, or use strings.