[Tutor] please help: conditional statement and printing element

kumar s ps_python at yahoo.com
Tue Jan 11 21:09:42 CET 2005


Dear group:
  I think I have got the answer :-)(


script:
>>> for i in range(len(psl)):
	col = split(psl[i],'\t')
	col1 = col[0]
	col1 = int(col1)
	col17 = int(col[17])
	if col1 == 25 and col17 == 1:
		print col[0]+
'\t'+col[1]+'\t'+col[9]+'\t'+col[10]+'\t'+col[11]

		
25	0	580:683	25	0
25	0	581:687	25	0
25	0	434:9	25	0
25	0	37:141	25	0
25	0	219:629	25	0
25	0	462:87	25	0
25	0	483:409	25	0
25	0	354:323	25	0
25	0	624:69	25	0
25	0	350:239	25	0


Is this a correct approach?

Thanks
K.


--- kumar s <ps_python at yahoo.com> wrote:

> Dear group, 
>   For some reason my brain cannot think of any other
> option than what I have in my script. Could any one
> please help me in suggesting.
> 
> What I have : (File name : psl)
> 22	2	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 22	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 24	1	457:411	25	0
> 22	0	457:411	25	0
> 21	0	457:411	25	0
> 25	0	457:411	25	0
> 25	0	457:411	25	0
> 
> 
> What to do:
> I want to print values that are 25 in column 1 and
> not
> the other values such as 24,22,21 etc.
> 
> 
> My script:
> >>> for i in range(len(psl)):
> 	col = split(psl[i],'\t')
> 	col1 = col[0]
> 	if col1 == 25:
> 		print col[0]+'\t'+col[1]+'\t'+col[17]
> 
> 
> >>>
> 
> Result: I get nothing. Am I doing something very
> wrong. Why isnt if col1 == 25: functional. 
> 
> My idea is to check if col[0] == 25: then print
> columns 1,18 etc. 
> 
> Can you please help me. 
> 
> Thanks
> K
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list