Another Very Much Newb with a?

I’m trying to figure out why the screenshot below, doesn’t print as?:

Enter value one:1
Enter value two:2
The sum is 12

Please paste code directly into messages as text, between triple
backticks:

code goes here

It makes it much easier for those of us using email. Not to mention the
vision impaired.

Your screenshot looks like this:

a = input('enter value one:')
b = input('enter value two:')
print('The sum is', a+b)

The input() function returns a line of text, which is a str (string).
That means that “a” and “b” are strings. Addition of strings joins them
together. Try it with some input which is words insted of numbers to
see.

You can get an int (integer) from a string like this:

s = "15"
n = int(s)

“n” is now a numeric value.

Adjust your code accordingly.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like

Got it! So obvious. Programming language is a whole new world for me. Thank you kindly.