Interessa anche a me la cosa<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
for i,c in enumerate(leggi):<br>
if c=="a" : print i<br>
<br></blockquote><div>se stessi cercando una parola intera potrei fare:<br> <br>sstr = "apici"<br>lsstr=len(sstr)<br>for i,c in enumerate(leggi):<br>
if c=="a" and leggi[i:i+lsstr]==sstr : print i<br><br>Ma mi conviene rispetto alle altre due proposte? Qual č la pių veloce?<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
sstr = "sa"<br>
lsstr = len(sstr)<br>
<br>
pos = leggi.find(sstr)<br>
print pos<br>
while True:<br>
new_pos = leggi.find(sstr, pos+lsstr)<br>
if new_pos == -1:<br>
break<br>
else:<br>
pos = new_pos<br>
print pos<br>
<br>
oppure<br>
<br>
import re<br>
expr = re.compile('sa')<br>
for e in expr.finditer(leggi):<br>
print e.start()<br>
<br>
<br></blockquote></div><br clear="all"><br>-- <br>----------------------------------------------------------------------<br>Giuseppe Amato<br>e-mail: <a href="mailto:giuamato@gmail.com" target="_blank">giuamato@gmail.com</a><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">
</div><br>
<div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>