12 Antworten
+ 3
I was confused for the same reason like Lothar.
One difference is that readline reads escape sequences, for example, a newline will also be saved in a variable.
https://code.sololearn.com/ct832uf2Quf0/?ref=app
Another difference is the arugment for input is used as the prompt message when readline takes an integer and reads that many characters from the input stream.
But it probably is not what making the difference in you case.
+ 13
Kabilan K ,
> input() function is to take an input from the user (done in the console) *[edit]*: input can have a prompt to the user that is shown when input is executed.
> readline() is a method of a file object (reading one line from a file that has been opend with open(<filename>, <filemode>)) *[edit]*: no user prompt possible.
+ 12
Kabilan K ,
it is always a good idea to share all required information with question...
> stdin from sys module does also use method named readline()
+ 4
+ 4
Alex Wairegi Lochard codebit is correct.
did you enter the inputs correctly? (the format that sololearn follows, providing all the inputs that a program needs on separate line)
+ 4
Sandeep ooh I see my mistake😅😅
+ 3
I see that you have completed a lot of courses. May I ask what have you confused?
Because their use cases seem very different to me.
+ 3
Alex Wairegi i think you should try again because it is not giving me any error. i am entering all three inputs on separate line
+ 2
Yesterday i solved a coding challenge in that if i use the input () function one test case didn't get passed but the readline() get passed on all the test cases
+ 2
Sandeep yes it gave me the EOF EXCEPTION
+ 1
Lothar but in a coding challenge i just used it as " data=sys.stdin.readline() " so how here the function works
+ 1
Lothar so how does that function get input from the user i mean until?