I have a string (Ex: BCVDBCVCBCBD) which i have converted into a list using the
seq_split = [string[i:i+1] for i in range (0, len(string),1)]
This resulted in a list like [‘B’ ,’C’,’V’………,’D’]
Now considering I take a user input, in the form of a number (say for example 2). I need to read every 2nd element from the start i.e 1st letter of sequence and the letter that is 2 positions away from the 1st letter (in count itll be the 3rd letter from start). The second time ill need to read the 2nd letter in the sequence and again the letter 2 positions away. i.e. the 2nd and 4th letter of the sequence . (I know its a little confusing so heres a detailed explanation)
If the user input is the number 2:
Then in a new list i will need to append (using the given string as example)- ‘BV’ , ‘CD’ , ‘VB’ and so on in a new list.
Similarly if the input is 4. Then the new list i create will have – ‘BB’, ‘CC’ etc…
I am confused as to how do i index them.
You can get the desired list with
where
iis the number chosen by the user. Example: