Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A function which sweep the indexes and doesn't stop at the first encounter

I would like to understand why the following code doesn't work

p=[-100,10,10,10,10,10,10,10,10,10,10]
[x/(1+.02)^(p.index(x)) for x in p]

what I was expecting is that for each $x$ (p.index(x)) would be an other index. I remember that since $10$ is of multiplicity $9$, (p.index(x)) is the indesx of the first occurence of $9$. So I ask if there is a function that sweep the index of all $x$ with or without multiplicity.

A function which sweep the indexes and doesn't stop at the first encounter

I would like to understand why the following code doesn't work

p=[-100,10,10,10,10,10,10,10,10,10,10]
[x/(1+.02)^(p.index(x)) for x in p]

what I was expecting is that for each $x$ (p.index(x)) would be an other index. I remember that since $10$ is of multiplicity $9$, (p.index(x)) is the indesx index of the first occurence of $9$. So I ask if there is a function that sweep the index of all $x$ with or without multiplicity.