In: Computer Science
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new python program with name "main.py" is created, which contains following code.
main.py :
def CommonLetters(mystring):
numletters=0 #declaring variable count
for letter in mystring: #using for checking each letter from
mystring
if letter == 'P': #checking letter P
numletters = numletters + 1 #increment value of count
elif letter=='y': #checking letter y
numletters = numletters + 1 #increment value of count
elif letter=='t': #checking letter t
numletters = numletters + 1 #increment value of count
elif letter=='h': #checking letter h
numletters = numletters + 1 #increment value of count
elif letter=='o': #checking letter o
numletters = numletters + 1 #increment value of count
elif letter=='n': #checking letter n
numletters = numletters + 1 #increment value of count
return numletters #return number of letters
#declaring variable to store boolean value
flag=True
#using while to ask user string
while flag:
#asking user to enter string
mystring=input("Enter String : ")
if mystring!="" : #if mystring is not empty
#calling method and passing parameter as mystring
print("Number of letters : ",CommonLetters(mystring))
else:
flag=False; #used to break the loop
*******************************
Screen used for Indentation :
======================================================
Output : Compile and Run main.py to get the screen as shown below
Screen 1 :main.py
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.