Question : Input after all prompts in python
Peter Otten
__peter__ at web.de
Mon Jun 11 08:14:26 EDT 2018
Karsten Hilbert wrote:
> On Mon, Jun 11, 2018 at 11:16:39AM +0000, Steven D'Aprano wrote:
>
>> > I want to prompt 3 questions together and then get input for the first
>> > question next to question as below.
>> >
>> > 1. Enter your name : _
>> > 2. Enter your age :
>> > 3. Enter your gender :
>> >
>> > After showing the below prompts, the cursor waits in first question for
>> > an input.
>>
>> How else do you expect to tell the three inputs apart?
>>
>> But okay.
>>
>>
>> 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 ;)
More information about the Python-list
mailing list