[Tutor] looping problem

2006-09-23 Thread kumar s
hi, the reason could be that I did not quite understand the concept of looping I have a list of 48 elements I want to create another two lists , listA and listB I want to loop through the list with 48 elements and select element with index 0,3,6,9,12 ..etc into listA select elements with

Re: [Tutor] looping problem

2006-09-23 Thread jim stockford
keep a counter in your loop. is this a homework question? On Sep 23, 2006, at 8:34 AM, kumar s wrote: hi, the reason could be that I did not quite understand the concept of looping I have a list of 48 elements I want to create another two lists , listA and listB I want to loop through

Re: [Tutor] looping problem

2006-09-23 Thread kumar s
hi, thank you. this is not a homework question. I have a very huge file of fasta sequence. GeneName \t AATTAAGGAA.. (1000 lines) AATAAGGA GeneName \t GGAGAGAGATTAAGAA (15000 lines) when I read this as: f2= open('myfile','r') dat =

Re: [Tutor] looping problem

2006-09-23 Thread Bob Gailer
kumar s wrote: [snip] so I want to select 0,3,6,9 elements into listA and 2,5,8,11 and so on elements into listB Here's a hint: for j in range(0, len(biglist), 3): # this will set j = 0, 3, 6, etc. -- Bob Gailer 510-978-4454 ___ Tutor

Re: [Tutor] looping problem

2006-09-23 Thread Python
On Sat, 2006-09-23 at 09:03 -0700, kumar s wrote: hi, thank you. this is not a homework question. I have a very huge file of fasta sequence. GeneName \t AATTAAGGAA.. (1000 lines) AATAAGGA GeneName \t GGAGAGAGATTAAGAA

Re: [Tutor] looping problem

2006-09-23 Thread jim stockford
#!/usr/bin/python # or whatever is the absolute path to python on your system counter = 0 for i in a,b,c,d,e,f,g : if counter%3 == 0 : print i + list one , counter, counter%3 if counter%3 == 1 : print i + list two , counter, counter%3 if

Re: [Tutor] looping problem

2006-09-23 Thread Kent Johnson
kumar s wrote: hi, thank you. this is not a homework question. I have a very huge file of fasta sequence. I want to create a dictionary where 'GeneName' as key and sequence of ATGC characters as value biglist = dat.split('\t') ['GeneName

Re: [Tutor] looping problem

2006-09-23 Thread John Fouhy
On 24/09/06, Python [EMAIL PROTECTED] wrote: slices may be the best way to go listA = biglist[0::3] # start from index 0 taking every third element listB = biglist[2::3] # start from index 2 taking every third element I'm not certain they would be.. If you do that, you will: 1. Create a

Re: [Tutor] looping problem

2006-09-23 Thread Kent Johnson
John Fouhy wrote: On 24/09/06, Python [EMAIL PROTECTED] wrote: slices may be the best way to go listA = biglist[0::3] # start from index 0 taking every third element listB = biglist[2::3] # start from index 2 taking every third element I'm not certain they would be.. If you do that, you