By default, Python does not include very flexible tools for developing applications on the terminal:
"Input" is pretty much the only option - for anyone on Unix (Linux or Mac OS), you can use the "curses" library to develop a complex app on the terminal (but it’s a lot more work than "input") .
The good news is that in general people ask how to catch an entrance without tighten <enter>
- in that case, one has to use a lib the part as curses or terminedia - but to plus of a enter, just create a function that you control, using various inputs. Unfortunately you can’t navigate with arrows, if the user wants to edit a line up, for example - but you can write a very quiet multilayered message:
def multi_input(msg, help="(digite uma linha em branco para terminar)"):
print(msg)
print(help)
resultado = []
linha = None
while linha != "":
linha = input()
resultado.append(linha)
return "\n".join(resultado)
Remembering that "input" already returns a string, so it is not necessary to do
str(input(...))
- the patterint( input(...) )
that is found in many pieces of code, including answers here, is no special syntax applicable toinput
- is simply called the "function"int
with whatever theinput
return - and if this is a valid string for conversion, returns an integer number.– jsbueno