> Den 05/01/2015 kl. 22.45 skrev Dariusz Mysior :
>
> I try develop this code to get a number of position this letter in word, and
> I have it but for example if i search letter "t" I get "1, 5, b", why I get b
> instead of 11???
>
> def gen2():
>count=0
>count2=0
>for a in zmienna
I try develop this code to get a number of position this letter in word,
and I have it but for example if i search letter "t" I get "1, 5, b", why I
get b instead of 11???
def gen2():
count=0
count2=0
for a in zmienna:
count2+=1
if a==szukana:
count+=1
You should use the string's count method: zmienna.count(szukana)
See help("string.count")
On Monday, January 5, 2015 4:32:06 PM UTC+2, Dariusz Mysior wrote:
>
> I want search count of szukana in zmienna but code below counting all 12
> letters from "traktorzysta" word
>
> szukana="t"
> zmienna
3 matches
Mail list logo