Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Hanswurst123523
5 months ago

You need to convert the inputs into integers using the int() function.

Example:

x = int(input())
y = int(input())
result = x + y
xxxcyberxxx
5 months ago

the “input” function returns a string. You need to convert the values to numbers so you can count on them

For integers, for example with the function “int”

naaman
5 months ago
Reply to  xxxcyberxxx

I hardly convert a string into a number with “int”.

Only one integer variable is defined with “int”.

Erzesel
5 months ago
Reply to  naaman

Nix heard of Typecasting?

By the way, this is not a unique thing of Python, but also in other languages the usual procedure.

xxxcyberxxx
5 months ago
Reply to  naaman

I hardly convert a string into a number with “int”.

This is explicitly about Python – you don’t seem to have any experience.

But extra for you, from Python:

>>> a = "42"
>>> b = int(a)
>>> type(a)

>>> type(b)

Only one integer variable is defined with “int”.

Python has no fixed typing, you also don’t set a type for a variable with int – you can only give a type note

naaman
5 months ago

All right.