Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # looping_counting.py
- def count_letters(word,letter):
- count = 0
- if letter not in word:
- print("That letter is not in the word in question.")
- raw_input("Press the Enter key to quit the program.")
- else:
- for char in word:
- if char == letter:
- count += 1
- times = count
- print("The letter %s, is in the word %s, %d time(s).") % (letter,
- word, times)
- def main():
- word = raw_input("Enter a word. ")
- letter = raw_input("Which letter did you want to see how many times it is"\
- +" present in the word? ")
- count_letters(word,letter)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement