python input | Sololearn: Learn to code for FREE!

+18

python input

x = input (x) y = input (y) print (x+y) what's the problem?

7/29/2018 2:57:42 AM

Life1219

90 Answers

New Answer

+98

x = int(input()) y = int(input()) print (x+y)

+29

x = input("x:" ) y = input("y:" ) print(x+y)

+15

Life1219 you have to input in 2 separate lines, like, 1 2 or let me now what input u are giving.

+15

Life1219 do you get any errors?

+15

Life1219 that's because of not giving proper number of inputs. One minute, I'll make a post to show that EDIT ~ https://www.sololearn.com/post/20154/?ref=app

+8

x = input() y = input() print(x+y)

+8

Life1219 when the code asks for input, write a number (or a string would work too) and then press enter. Then give your second number or a string on the second line.

+7

Nikhil EOFerror

+7

yash Nikhil Nikhil Dhama thanks. now i know.

+7

n = input("What is your name? ") s = input("What is your surname? ") y = input("Write an year when you born: ") age = 2021 - int(y) print("Your name is " + n + ". " + "Your surname is " + s + ". " + "You have " + str(age) + " years.") Code works

+5

Nikhil Dhama it isn't work, too.

+5

x = int(input()) y = int(input()) print (x+y)

+4

NezhnyjVampir yash Nikhil Dhama I used code playground. but it doesn't work.

+4

You are taking string inputs from the user. When you try to print x+y, It concatenates the two inputs. If you are dealing with intergers, use the below code x = int(input()) y = int(input()) print(x+y) For float(decimal) values, use the below code x = float(input()) x = float(input()) print(x+y) For multiple integers inputs: x = (int(i) for i in input().split()) print(sum(x)) The above lines read multiple numbers from user and store them as tuple. But the problem is user should give the numbers in single line. sum(x) will add all numbers that are stored in x.

+4

x=input("x") y=input("y") print(x+y)

+4

x = input() y= input() print(x* y )

+3

x=int(input()) y=int(input()) print(x+y) This is correct

+3

The problem is that its a syntax error. Where the input function only takes a string value, as a parameter, which is a default message for the user before entering input value. Here x is a variable as its not surrounded by quotes. And thus an error.

+2

x=int(input()) y=int(input()) print(x+y)

+2

The problem is the input is taken the string type by default. So, wen chage the datatype when we declare the input value. We can change the data type as below way x=int(input ()) y=iny(input ()) print (x+y) Now you can take the output of the code. If you can't chage that you didn't get expected output from these code