0
[Solved] How come Python knows to wait for the user to press enter twice and only then output a multiline input as in this code?
Hello. I was expecting Python to just print one line or throw an error after typing "Hehe" for the first line and pressing enter. I was not expecting it to perceive the first enter signal as an input line break, letting me write another sentence to then perceive two successive enter signals as a case of "else" and actually break the loop. How come it perceives the first enter as part of input while output stuff when enter itself is inputted twice? Thank you. (edited because I'd realized I left out a part, it was confusing, soz) https://code.sololearn.com/c4S3oTVoLSqC/?ref=app
3 ответов
+ 3
The while loop keeps asking for input until txt takes a value that is interpreted by python as False. One way this happens is if you hit enter without giving any input.
+ 2
Chris Coder No I was being a moron. Thank you though :-)
+ 1
Simon Sauter I get it. If you started replying to my attempt at clarification, I am sorry. I hope I wasn't too late to remove it. (it being a second post asking more about it)
Thank you!
Yeah, I forgot how input's not in a while loop most of the time when I do an exercise, which is why the first time I press enter I get a result. I wish I could see it myself.