With this in mind we can change the following code:
def MinimumSkew(Genome):
positions = []
skew = SkewArray(Genome)
minimum = min(skew)
for i in range(0, len(Genome)):
if skew[i] == minimum:
positions.append(i)
return positions
for this:
def MinimumSkew(Genome):
skew = SkewArray(Genome)
minimum = min(skew)
return [i for i in range(0, len(Genome)) if skew[i] == minimum]
The "formula" used has the following basic structure:
[expression for item in list if conditional]
which is equivalent to:
for item in list:
if conditional:
expression
In [MinimumSkew.py](https://coolneng.duckdns.org/gitea/coolneng/biology-meets-programming/src/branch/master/Code/MinimumSkew.py)
Conditions met to use list comprehensions:
- Creation of a list: positions
- Filter of data: if skew[i] == minimum
- Iterator: range(0, len(Genome))
With this in mind we can change the following code:
def MinimumSkew(Genome):
positions = []
skew = SkewArray(Genome)
minimum = min(skew)
for i in range(0, len(Genome)):
if skew[i] == minimum:
positions.append(i)
return positions
for this:
def MinimumSkew(Genome):
skew = SkewArray(Genome)
minimum = min(skew)
return [i for i in range(0, len(Genome)) if skew[i] == minimum]
The "formula" used has the following basic structure:
```
[expression for item in list if conditional]
```
which is equivalent to:
```
for item in list:
if conditional:
expression
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In MinimumSkew.py
Conditions met to use list comprehensions:
With this in mind we can change the following code:
for this:
The "formula" used has the following basic structure:
which is equivalent to:
That is elegant, thanks!