+ 1
Different outputs for almost same code
If i write input("enter") then it asks for input but only shows 'enter' in output.Why? whereas if i write a=input("enter") print(a) then it asks for input and works good.
5 ответов
+ 4
In the first case :
U r asking the python interpreter to take the input but not assigning any variable to store the input value , so it takes the input and throws it away afterwards
But in the second case:
U have assigned a variable and later u have asked to print , hence u get the output
+ 3
In the first example you're only asking for an input; in the second one you're specifying an output as well.
INPUT: input("enter") or a = input("enter")
OUTPUT: print(a)
You can actually write it all in one go like this:
print("Your input is: " + input())
This gives input as the parameter for print.
+ 2
Python unlike other languages has input function which allows u to prompt any message to the user
so u only get the prompt ("enter") in first case
+ 1
What i am trying to say is that in the first example the output it shows is enter and nothing else
+ 1
Thanks Tony 3000!