[Tutor] learning to programming questions part 2

keith papa keithadu at live.com
Tue Jul 1 21:39:10 CEST 2014





Hi am leaning to program in python with the book "think python" I have read both chapters 1 and 2 about string and variables and keywords., so I decide to look online for some practice to help me and I found something on http://www.pyschools.com/
1.Write the function countA(word) that takes in a word as argument and returns the number of 'a' in that word.Examples    >>> countA("apple")
    1
    >>> countA("Apple")
    0
    >>> countA("Banana")
    3The code starts out with>>>def countA(word):I have tried many different code to get the answer but am getting it right.I have tried:1. >>>def countA(apple):("a")2. >>>print ("apple")
def count('a')3. >>>("apple").count("a")4. >>>countA= apple.count ("a")#help me solve this
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140701/367e66fd/attachment-0001.html>


More information about the Tutor mailing list