Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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."""
- def count_words(string):
- for word in string.split():
- if word.endswith("on") == True:
- print(word,":",string.count(word))
- string = string.replace(word,'')
- print(string)
- count_words(my_string)
- gameon : 2
- gameon : 0
- briton : 2
- Python : 2
- briton : 0
Add Comment
Please, Sign In to add comment