Can some1 help with this simple operation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can some1 help with this simple operation

print("test") print ("enter the amount now") X = input ( ) print (X) print("enter usage now") Y = input ( ) print (Y) print int (X) +(Y) print("the calculated value is:")

18th Jan 2017, 12:14 PM
Shane Gibson
Shane Gibson - avatar
7 Answers
+ 4
Right... You are using 3.x ( I try with 2.7 )... you must set parenthesis to your print statement, and you was right for int() function ^^ print(int(X)+int(Y))
18th Jan 2017, 12:44 PM
visph
visph - avatar
+ 3
print int(X)+int(Y) # you forgot the 2nd 'int'...
18th Jan 2017, 12:22 PM
visph
visph - avatar
+ 2
I make a mistake ^^ print X+Y # no int() function in Python... If Python 3.x: print(X+Y) In code playground this is Python 3.x, and the user inputs may to be all done just before starting script...
18th Jan 2017, 12:32 PM
visph
visph - avatar
+ 1
ok I used 2 figures 24 and 12 should add to 36 but code is coming out as 2412
18th Jan 2017, 12:40 PM
Shane Gibson
Shane Gibson - avatar
0
ok will try this
18th Jan 2017, 12:23 PM
Shane Gibson
Shane Gibson - avatar
0
thank you that worked
18th Jan 2017, 12:50 PM
Shane Gibson
Shane Gibson - avatar
0
make sure the variables aren't capital letters too
19th Jan 2017, 6:09 PM
Ryan S
Ryan S - avatar