[Tutor] taking a tuple with input

Alan Gauld alan.gauld at btinternet.com
Sun Oct 27 01:39:49 CEST 2013


On 26/10/13 20:32, Siva Cn wrote:
>
> p1 = tuple([float(ele) for ele in input('Please type ...').split()])

If you do it all in one line like that you dpn;t need the [] inside the 
tuple() call. The generator expressoion will work directly.

But of course a single line like that will be hard to debug if you get 
anything wrong.

You have to decide which trade off you prefer, size v complexity.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list