PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/helloworld/cpiski.py

https://bitbucket.org/mariastepanova/good-one
Python | 21 lines | 11 code | 3 blank | 7 comment | 3 complexity | 6699323b302deb4ec06acb98a183d0af MD5 | raw file
 1def count(l, el):
 2	'''
 3	>>> count([1, 1, 1], 1)
 4	2
 5	>>> count([2, 2], 0)
 6	0
 7	'''
 8	result = 0
 9	for e in l:
10		# increment result of e equals to el
11		if e == el:
12			result = result + 1
13	return result
14
15		
16if __name__ == '__main__':
17	import doctest
18	doctest.testmod()	
19	print count([1,1], 1)
20	
21	print "@@@@" + str(space.splitstring("foo bhar"))