Skip to content
Advertisement

Creating a list of positions of a substring within a string (DNA) (Python 3)

I am doing a bioinformatics course and I am trying to write a function to find all occurrences of a substring within a string.

JavaScript

The output above should exactly match the following:

[2, 4, 10]

[2, 5, 6, 15, 17, 18]

How can I fix this? Preferably without using regular expressions.

Advertisement

Answer

It looks like you badly indented the code, the

JavaScript

has to be outside of the inner cycle.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement