+ 1

Hi guys! Please, does anyone knows the difference between INPUT and PRINT?

For example: I tried the following code: Input('\n smile') Output: smile Traceback (most recent call last): File "./Playground/file0.py", line 2, in <module> input('\n smile') EOFError: EOF when reading a line BUT If I use: print('\n smile') Output: smile What is happening? Why the first one shows an Error and the sencond doesn't not? Thanks

21st Dec 2019, 4:27 PM
Ana Carolina
17 Antworten
+ 4
You use "print()" when you want to print something to the console. You use "input()" when you want to take an input of some data from the user of your program. That is the difference. The string inside the brackets for input() is the prompt the user will see when the program runs. In the SoloLearn code playground, the prompt is shown on the console, and that is why you are able to see it. However, you won't see what the user input is unless you print it. To see what I mean, try this code: word = input("Enter a word:\n") print(word) When the code playground prompts you for an input, enter any word you like.
22nd Dec 2019, 4:39 PM
Njeri
Njeri - avatar
+ 3
Input asks for the user's input, and in Playground here, you need to separate between each input by jumping to a new line when the input is requested. For the Print, it displays an interger, a string, etc...
21st Dec 2019, 7:24 PM
Souhail Ben Belhassen
Souhail Ben Belhassen - avatar
+ 3
Python is case-sensitive, so it needs to be "input" rather than "Input" for it to work. Python will see "Input" as something different to "input" and give a NameError because "Input" has not been defined in the code.
22nd Dec 2019, 4:32 PM
Njeri
Njeri - avatar
+ 3
The EOFError happens when your program is expecting something, but the something is not found, so your program ends prematurely. In the case of inputs, it will happen if you don't give a user input when the program runs. If there is only one input call, and you don't give an input for it, it will intepret the input as the empty string and only show the prompt (if there is one). However, if you have more than one input call, say two, and you don't give any inputs or you only give one, then you will get an EOFError, because the program is expecting two.
22nd Dec 2019, 4:51 PM
Njeri
Njeri - avatar
+ 3
EOF error means end of file ,which means that the program was calling for an input but failed to have any available input to READ in your case input ('\n smile')
23rd Dec 2019, 1:39 PM
yara moharram
yara moharram - avatar
+ 2
Thomas, you are so boring! You think that you are an expert, but you're not. If you don't know to help and give instructions to people, so in that case, why are you here yet? Why are you so stupid and silly? I am beginner, stupid and this is my second day learning here. I don't need to feel bad if I have doubt and came a stupid guy like you to show nothing, to answer nothing. I never will ask help for people like you, never. Now, go to be more useful because your comments are like you, poor!
22nd Dec 2019, 2:41 PM
Ana Carolina
+ 2
Njeri, Thanks a lot for your answer. I have no doubts that people like you, make the difference in this community! I don't think I could receive a better explanation to my doubts. I learned more than I expect with your answer. Again, Thank you so much!
22nd Dec 2019, 6:30 PM
Ana Carolina
+ 1
Thomas, I want to know the difference and not where they take place. Maybe you don't understand my question. If you don't know explain, than don't say "sorry" because this will not solve my doubt.
21st Dec 2019, 10:36 PM
Ana Carolina
+ 1
Jan? I did a new test and I found the error. Have a look in this example. The problem is where I start the command using a Capital Letter. If you do: input('\n smile') Output: smile But If you do: Input('\n smile') Output: Traceback (most recent call last): File "./Playground/file0.py", line 5, in <module> Input('\n smile') NameError: name 'Input' is not defined Thanks for your time and answer. https://code.sololearn.com/291/#py
21st Dec 2019, 10:43 PM
Ana Carolina
+ 1
Ana Carolina Thank you and I'm glad it helped.
22nd Dec 2019, 6:56 PM
Njeri
Njeri - avatar
23rd Dec 2019, 11:27 AM
Surya Prakash
Surya Prakash - avatar
+ 1
Thanks for all contributions,guys!
23rd Dec 2019, 8:39 PM
Ana Carolina
0
Grille hyper artistique Recherche y â ù s le Recherche
22nd Dec 2019, 4:01 PM
MamaDiouma Diallo
MamaDiouma Diallo - avatar
0
Souhail Belhassen, Thanks!
22nd Dec 2019, 6:33 PM
Ana Carolina
0
Print is output, input is for getting user input
23rd Dec 2019, 2:03 AM
OnesAndZeroes10
OnesAndZeroes10 - avatar
- 1
Ana Carolina , if you really ask for the difference between "input" and "print", I would say, you better start the python course from the beginn.
21st Dec 2019, 7:19 PM
Coding Cat
Coding Cat - avatar
- 2
I've corrected my answer. Wish you good luck for your programming future 👍
21st Dec 2019, 11:08 PM
Coding Cat
Coding Cat - avatar