[Tutor] Weird situation in using .split() function

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Tue Nov 29 18:15:30 CET 2005


Hello group:

I have a list t and the elements are tab limited. 
there are 2 columns:
>>>t
['STAG2\tmiR-101', 'SMARCA1\tmiR-101',
'RAP2C\tmiR-101', 'DDX3Y\tmiR-101',
'AGRN\tmiR-101\tmiR-144', 'EPB41\tmiR-101\tmiR-144',
'PUM1\tmiR-101\tmiR-144',
'KIAA1573\tmiR-101\tmiR-144',
'ST6GALNAC3\tmiR-101\tmiR-144',
'CAPZA1\tmiR-101\tmiR-144']
>>> for i in t:
	i = i.strip('')
	cols = i.split('\t')
	print cols[0]

	
STAG2
SMARCA1
RAP2C
DDX3Y
AGRN
EPB41
PUM1
KIAA1573
ST6GALNAC3
CAPZA1

>>> for i in t:
	i = i.strip('')
	cols = i.split('\t')
	print cols[1]

	
miR-101
miR-101
miR-101
miR-101
miR-101
miR-101
miR-101
miR-101
miR-101
miR-101

>>> for i in t:
	i = i.strip('')
	cols = i.split('\t')
	print cols[2]

	

Traceback (most recent call last):
  File "<pyshell#527>", line 4, in -toplevel-
    print cols[2]
IndexError: list index out of range

>>> for i in t:
	i = i.strip('')
	cols = i.split('\t')
	print cols

	
['STAG2', 'miR-101']
['SMARCA1', 'miR-101']
['RAP2C', 'miR-101']
['DDX3Y', 'miR-101']
['AGRN', 'miR-101', 'miR-144']
['EPB41', 'miR-101', 'miR-144']
['PUM1', 'miR-101', 'miR-144']
['KIAA1573', 'miR-101', 'miR-144']
['ST6GALNAC3', 'miR-101', 'miR-144']
['CAPZA1', 'miR-101', 'miR-144']


When I try to Print column 2 (0,1,2 which is miR-144)
elements why is it saying index out of range whern
miR-144 is already there. 

Can any one please help me. 

thanks
Srini


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the Tutor mailing list