Question: USING PYTHON PROGRAMMING AND WHILE LOOPS DO NOT USE BREAK,PASS,CONTINUE. DO NOT USE BUILT-IN FUNCTIONS AND FOR LOOPS For this part of the homework you
USING PYTHON PROGRAMMING AND WHILE LOOPS DO NOT USE BREAK,PASS,CONTINUE. DO NOT USE BUILT-IN FUNCTIONS AND FOR LOOPS
For this part of the homework you will create a
program that asks the user for
a string and a letter, an
d then counts how many times that letter appears in
the string. You must create a function called
numLetter()
that handles
counting the number of times the letter appears
, and prints out the results
. It
must be case
in
sensitive.
The program must contain
a
main()
and a function called
numLetter()
,
implemented as described in the function header comment given below.
(You should include this function header comment in your own code.)
###########################################################
# numLetter(
) counts the instances of a letter
in
a string
# Input: aString; a string of the phrase to search in
# letter; a single character to search for
# Output: None
SAMPLE OUTPUT:
bash
-
4.1$ python hw5_part1.py
Enter a string:
Dogs are good, dogs are great.
Enter a letter to search for:
d
There are 3 instances of d in the string
bash
-
4.1$ python hw5_part1.py
Enter a string:
Peter
Piper picked a peck of pickled
peppers!
Enter a letter to search for:
P
There are 9 instances of P in the string
bash
-
4.1$ python hw5_part1.py
Enter a string:
act tta aga agg aga tat acc atg ggt tct
Enter a letter to search for:
G
There are 7 instances o
f G in the string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
