how do i add a digit to an integer in python ?
value = 9
#add a 9 to "value" to get 99
print(value)
So i want the console to return :
99
I tryed to do
value.append(9)
but it didnt work
CodePudding user response:
You can convert int to str, concatenate the strings, and the convert back to int:
value = 9
add = 9
print(int(str(value) str(add)))
CodePudding user response:
I think you could convert your number to a string, add those together, and then convert it back into an integer. Something like
var1 = "9"
var2 = var1 var1
convertedAnswer = int(var2)
print(convertedAnswer)
could work?