How to read formatted input in python?

Posted by eSKay on Stack Overflow See other posts from Stack Overflow or by eSKay
Published on 2009-09-09T06:19:59Z Indexed on 2010/04/07 9:13 UTC
Read the original article Hit count: 455

Filed under:
|

I want to read from stdin five numbers entered as follows:

3, 4, 5, 1, 8

into seperate variables a,b,c,d & e.

How do I do this in python?

I tried this:

import string
a=input()
b=a.split(', ')

for two integers, but it does not work. I get:

Traceback (most recent call last):
  File "C:\Users\Desktop\comb.py", line 3, in <module>
    b=a.split(', ')
AttributeError: 'tuple' object has no attribute 'split'

How to do this? and suppose I have not a fixed but a variable number n integers. Then?

© Stack Overflow or respective owner

Related posts about python

Related posts about input