Question : Input after all prompts in python

2018-06-11 Thread mohan4h
Everyone,

I am very new to python. I am trying to achieve the below in it, but i am 
unable to find suitable documentation to guide me on the same.

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 to achieve this in python. Please help on the same.

Regards
Mohan C
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question : Input after all prompts in python

2018-06-11 Thread mohan4h
On Monday, June 11, 2018 at 9:13:04 PM UTC+8, Karsten Hilbert wrote:
> On Mon, Jun 11, 2018 at 02:52:53PM +0200, Peter Otten wrote:
> 
> > 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.
> 
> Agreed.
> 
> Note that I had a lurking suspicion this whole thing amounts
> to a homework assignment (which I didn't say, however) ... ;-)
> 
> Karsten
> --

Thanks all for your support,

I am a data storage admin by profession, starting to learn python as a hobby. I 
was just curious to learn this task, since this task is usually tricky in 
command prompt.

BTW i tried the code above, but i encountered a syntax error.

print(u"\u001b[{}A".format(n), flush=True, end="")
 ^
SyntaxError :invalid syntax

I m trying this in a centos el7 bash terminal.
If i try running as
print(u"\u001b[{}A".format(n))
It works but the right function does not move the cursor right.

is it possible to achieve the same using sys.stdout.write.

Regards
Mohan C 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question : Input after all prompts in python

2018-06-12 Thread mohan4h
On Tuesday, June 12, 2018 at 7:37:25 PM UTC+8, Bart wrote:
> On 11/06/2018 12:16, Steven D'Aprano wrote:
> > On Mon, 11 Jun 2018 01:44:19 -0700, mohan4h wrote:
> > 
> >> Everyone,
> >>
> >> I am very new to python. I am trying to achieve the below in it, but i
> >> am unable to find suitable documentation to guide me on the same.
> >>
> >> 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("")
> 
> This will do the job, eventually:
> 
> print("1. Enter your name :")
> print("2. Enter your age :")
> print("3. Enter your gender :")
> name = input("")
> age = input("")
> gender = input("")
> 
> print("1. Enter your name :",name)
> print("2. Enter your age :",age)
> print("3. Enter your gender :",gender)
> 
> -- 
> bart

Everyone,

I want to thank you all for your support, As advised Steven D'Aprano and 
Wolfgang Maier, I tried the same code in python3 and it worked like a wonder.
I would like to thank Peter Otten for the solution.

I learned something new.

Thanks for all your support.

Regards
Mohan C
-- 
https://mail.python.org/mailman/listinfo/python-list


Help Needed : script weird result.

2018-09-01 Thread mohan4h
All,

I m trying to run this small script to find the lowest of the given array of 
numbers. The script works fine for various combination of inputs but fails in a 
weird way for a particular set of inputs, can anyone point the mistake in the 
script and the behavior.

Script

x = input ("Enter the numbers separated by space and press ENTER :")
x = x.split(" ")

def checkmin(arr):
lowest = arr[0]
for count in range(0,len(arr),1):
if arr[count] < lowest :
lowest = arr[count]
else :
pass
print (lowest)
return lowest

minimum = checkmin(x)
print ("Lowest : {0}".format (minimum))


Weird output is as below.

== RESTART: C:\Users\mohan\Desktop\temp.py ==
Enter the numbers separated by space and press ENTER :5 90 63 82 59 24
5
5
5
5
5
24
Lowest : 24

Regards
Mohan C
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help Needed : script weird result.

2018-09-01 Thread mohan4h
On Sunday, September 2, 2018 at 1:12:17 AM UTC+8, [email protected] wrote:
> All,
> 
> I m trying to run this small script to find the lowest of the given array of 
> numbers. The script works fine for various combination of inputs but fails in 
> a weird way for a particular set of inputs, can anyone point the mistake in 
> the script and the behavior.
> 
> Script
> 
> x = input ("Enter the numbers separated by space and press ENTER :")
> x = x.split(" ")
> 
> def checkmin(arr):
> lowest = arr[0]
> for count in range(0,len(arr),1):
> if arr[count] < lowest :
> lowest = arr[count]
> else :
> pass
> print (lowest)
> return lowest
> 
> minimum = checkmin(x)
> print ("Lowest : {0}".format (minimum))
> 
> 
> Weird output is as below.
> 
> == RESTART: C:\Users\mohan\Desktop\temp.py ==
> Enter the numbers separated by space and press ENTER :5 90 63 82 59 24
> 5
> 5
> 5
> 5
> 5
> 24
> Lowest : 24
> 
> Regards
> Mohan C

Thanks to Duncan, Joel, Peter and Dan.

Now I understood what was wrong with the script and i fixed it, 
Now my scripts executes as expected and also i understand a concept in type 
casting.

As always this group is awesome and responsive, Thanks again guys.

Regards
Mohan C
-- 
https://mail.python.org/mailman/listinfo/python-list