How do I concatenate two integer numbers (for example: 10 and 20) in Python to get a returned value of 1020?
Just to give another solution:
def concat_ints(a, b):
return a*(10**len(str(b)))+b
>>> concat_ints(10, 20)
1020
The best way to do this in python was given in the accepted answer - but if you want to do this in jinja2 templates - the concatenation operator ~
gives you a neat way of doing this since it looks for the unicode representation of all objects, thus, you can 'concatenate integers' as well.
That is you can do this (given a=10
and b=20
):
{{ a ~ b }}