daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. my_string = """Strings are gameon amongst gameon the most popular data types in Python. We can create the strings by enclosing characters briton in quotes. Python treats briton single quotes the same as double quotes."""
  2. def count_words(string):
  3.     for word in string.split():
  4.         if word.endswith("on") == True:
  5.             print(word,":",string.count(word))
  6.             string = string.replace(word,'')
  7.             print(string)
  8. count_words(my_string)
  9.    
  10. gameon : 2
  11. gameon : 0
  12. briton : 2
  13. Python : 2
  14. briton : 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top