+ 1
python 09 + 23
I was dealing with a bunch of data, and I wanted to add the number 09 with another number. Are there any suggestions? e.g. print(09+1)
5 ответов
+ 1
either
int("09") + 23
or
"09" + str(23)
you can't add a string to an number(int/float)
+ 1
A thing to note is...
in our mathematics 09 is considered as an Integer
but in python its an invalid token itself
NO INTEGER IN ITS TRUE FORM CAN CONTAIN 0 AT FIRST
so, even print(09) itself will give you error msg
0
perhaps I didn't express it clearly. What I meant is that number 9 must stay in the form of "09" (doesn't matter if it's a int or str), and plus another number:
print(09+4)
SyntaxError: invalid token
0
Is this what you are are trying to do?:-
print('09 + 23 = {}'.format(int('09') + 23))
# or
mynum = '09'
print(mynum, '+ 23 = {}'.format(int(mynum) + 23))