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="traktorzysta" 
>  
>  
> def gen(): 
>     count=int(0) 
>     for a in zmienna: 
>         if szukana in zmienna: 
>             count+=1 
>         else: 
>             continue 
>     return count 
>  
>  
> print("Literka '",szukana,"' w słowie ",zmienna, 
>       "wystąpiła ",gen()," razy") 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dcfa01b2-4e43-475e-99ad-ebdef6e8c4ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to