Don't like ads? PRO users don't see any ads ;-)
Guest

6-4

By: Mars83 on Oct 9th, 2011  |  syntax: Python  |  size: 0.42 KB  |  hits: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #! /usr/bin/env python3.2
  2. # -*- coding: utf-8 -*-
  3.  
  4. # main.py
  5. """ Task: Exercise 6.4
  6.    There is a string method called count that is similar to the function in
  7.    the previous exercise. Read the documentation of this method at
  8.    docs.python.org/library/string.html and write an invocation that counts the
  9.    number of times the letter a occurs in 'banana'.
  10. """
  11.  
  12. ''' Main '''
  13. word = 'banana'
  14. print(word.count('a'))
  15.