+ 2
A simple question about string add operation
print(int("0010"+"1011")) #why output 00101011 is not correct?
3 Respostas
+ 2
thanks all~~~You all are so friendly .ok,I understand it.haha the question seem to be too stupid.
+ 1
because when you use int() python by default eliminates all the 0's that are in front of the integer, if you want the 0's to show then don't use int ()
+ 1
Because you turned the value into an integer after adding the strings together, it discards the extra 0's and makes it 101011.
Take off the int() in order to make it 00101011.