+ 24
python input
x = input (x) y = input (y) print (x+y) what's the problem?
133 Respostas
+ 126
x = int(input())
y = int(input())
print (x+y)
+ 37
x = input("x:" )
y = input("y:" )
print(x+y)
+ 17
Life1219
you have to input in 2 separate lines,
like,
1
2
or let me now what input u are giving.
+ 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
+ 14
Life1219 do you get any errors?
+ 11
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
+ 9
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.
+ 8
Nikhil EOFerror
+ 7
x = input()
y = input()
print(x+y)
+ 7
+ 5
Nikhil Dhama
it isn't work, too.
+ 4
+ 4
x=int(input())
y=int(input())
print(x+y)
This is correct
+ 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 )
+ 4
x = int(input())
y = int(input())
print (x+y)
+ 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
When you use the input() function , the space inside the braces is where your input( the thing you're writing in playground) is supposed to be.
There should not be any variable in the braces.
In the case where you are trying to write a prompt for the input, you can put a string in the braces.
For clarification:
x is a variable
'x' is a string