Homework exercise to prepare for class on Wednesday, 1/20
Purpose:
- practice working with for-loops
Exercise(s)
Do at least one of the following exercises:
-
Write a program that asks the user for a word and then counts how many e's that word contains.
-
Write a program that asks the user for a word and an individual letter. The program should then replace all occurrences of the letter in the word with an underscore and print out the result. For example: given the word mammal and the letter m the program would print _a_ _al
-
The file simple_code.py contains the definition for a simple function that encodes single letters. The function is called 'encode' and takes one parameter. Given a single letter string as the parameter, it returns another letter. For example, when called with parameter value "a", the function returns "b", and so on.
Add a function to simple_code.py, that asks the user for a word and then creates a new string that is the encoding of the word. That is, each letter of the original word should get encoded using the given function 'encode' and the encoded letters should be "glued" back together into a single string.