Re: problem with for and if

2015-01-05 Thread Steven D'Aprano
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 >

Re: problem with for and if

2015-01-05 Thread Shiyao Ma
On Jan 05 at 22:38 +0800, Shiyao Ma wrote: > More preferably, you should repetitively use "str.find" > > Or just use `max(0,len(zmienna.split(szukana))-1)` Forgot there was a `str.count`, ;). -- Shiyao Ma http://introo.me -- https://mail.python.org/mailman/listinfo/python-list

Re: problem with for and if

2015-01-05 Thread MRAB
On 2015-01-05 14:27, 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

Re: problem with for and if

2015-01-05 Thread Dariusz Mysior
W dniu poniedziałek, 5 stycznia 2015 15:28:07 UTC+1 użytkownik Dariusz Mysior napisał: > 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 zmien

Re: problem with for and if

2015-01-05 Thread Chris Warrick
On Mon, Jan 5, 2015 at 3:27 PM, Dariusz Mysior wrote: > I want search count of szukana in zmienna but code below counting all 12 > letters from "traktorzysta" word First off, I recommend that you do not write code in Polish — use English so that everyone can understand your code. Your error is

Re: problem with for and if

2015-01-05 Thread YBM
Le 05/01/2015 15:27, Dariusz Mysior a écrit : 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

Re: problem with for and if

2015-01-05 Thread Shiyao Ma
On Jan 05 at 06:27 -0800, 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: >