Python, how to concatenate 2 strings of same value, 0

Post for Python. I did read other posts and sure this isn’t a duplicate

I created two variables in my Python and they both have the string 0. I tried with 2 different strings of 1 and 0 and when I concatenate them I get 10. But when I concatenate 0 and 0 I get another 0. Code:

a = 0
b = 0
b = int(str(a)+str(b))
print(b)

Output: 0. I would like the output to be 00

Answer

Having leading zeros in a number will be removed. It won’t change the value so Python just removes them.

As you can see:

>>> 0123
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>> 

Putting 0 in front of a literal gives an error. But if you just do:

>>> int('0123')
123
>>> 

It would automatically strip the zeros.

To fix it don’t change it to a integer:

a = 0
b = 0
x = str(a) + str(b)
print(x)

Output:

00