Question : Input after all prompts in python

Peter Otten __peter__ at web.de
Mon Jun 11 08:52:53 EDT 2018


Karsten Hilbert wrote:

> On Mon, Jun 11, 2018 at 02:14:26PM +0200, Peter Otten wrote:
> 
>> >> print("1. Enter your name :")
>> >> print("2. Enter your age :")
>> >> print("3. Enter your gender :")
>> >> name = input("")
>> >> age = input("")
>> >> gender = input("")
>> > 
>> > That doesn't solve the "next to" part in
>> > 
>> > get input for the first question next to question
>> 
>> Easy:
>> 
>> def up(n):
>>     print("\u001b[{}A".format(n), flush=True, end="")
>> 
>> def right(n):
>>     print("\u001b[{}C".format(n), flush=True, end="")
>> 
>> print("1. Enter your name:")
>> print("2. Enter your age:")
>> print("3. Enter your gender:")
>> up(3)
>> right(22)
>> name = input("")
>> right(22)
>> age = input("")
>> right(22)
>> gender = input("")
>> 
>> If it doesn't work you are using the wrong terminal ;)
> 
> Sure, but notice how I said "(easily)" in the original answer ?

Actually, no.
 
> The above is NOT easy for an OP who has to ask the original question.

If the above hack works in the OP's environment it's certainly as easy as it 
can get; he just has to copy the up() and right() functions, and maybe adapt 
the arguments.

The learning curve for tkinter or curses is steep by comparison.




More information about the Python-list mailing list