My current code reads user input until line-break. But I am trying to change that to a format, where the user can write input until strg+d to end his input.
I currently do it like this:
input = raw_input ("Input: ")
But how can I change that to an EOF-Ready version?
Use
file.read
:According to the documentation:
BTW, dont' use
input
as a variable name. It shadows builtin functioninput
.With
sys.stdin.readline()
you could write like this:Remember, whatever your input is, it is a string.
For
raw_input
orinput
version, write like this:This worked for me in Python 3:
You could also do the following: