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
pozycja.append(count2)
return pozycja
print("3. Literka '",szukana,"' w słowie ",zmienna,
"wystąpiła " ,gen(),"razy w kolejności")
#print(gen2())
print(", ".join(["%x" % a for a in gen2()]))
W dniu poniedziałek, 5 stycznia 2015 16:45:19 UTC+1 użytkownik Zoltán Bege
napisał:
>
> 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/9576f3af-e6c5-4713-a4c7-271279a78165%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.