0
Why is it not displaying the input and nither is it performing the operation?
9 ответов
+ 7
There is still some room for improvement.
(1) try to get numbers as int direct when input is called.
(2) there is no need to have input values captured separate for each operation. Just place it once as shown in the code below:
x =["add","subtract",]
user_input=input()
num_1 = int(input("enter first number:"))
num_2 = int(input("enter second number"))
if user_input == x[0]:
print(num_1 + num_2)
elif user_input == x[1]:
print (num_1 - num_2 )
+ 6
Sameel Khan , you are very welcome. happy coding!
+ 3
Sameel Khan It will be shown in output when you are asked to enter a number. If you don't want anything except the output either you can creat a function to clear screen(in cmd/terminal) or just remove "enter a number"
+ 1
you dont need = in print statement
+ 1
uhh...
You have used
print = (num_1 + num_2)
but it is used as
print( num_1 + num_2 )
Also, SL doesn't support multiple inputs so you jave to run it in any other IDE
+ 1
Use print() as function not as a variable..
Modify the stmts to..
print(int(num_1 )+int(num_2 ))
print(int(num_1 )-int(num_2 ))
Now you'll get the required o/p
+ 1
Lothar thanks for the suggestion it's definitely more efficient that way ,I have much to learn :)
0
Thank you all for the help
0
I had one more problem ,
Why does the input("enter a number") show in the output ,it is just supposed to be for the user right?