Formatted Input

Larry Bates lbates at websafe.com
Mon Mar 12 10:14:54 EDT 2007


Deep wrote:
> Hi all,
> I am a newbie to python
> I have an input of form
> <one number> space <another number>
> ie.
> 4 3
> how can i assign these numbers to my variables??
> 

Or with list comprehension:

n1, n2 = [int(n) for n in raw_input().split()]

Neither of these methods checks for errors (e.g. non-integers)

-Larry



More information about the Python-list mailing list