Question: the following function, hasFourHs is supposed to return to True if there are at least 4 'H's in the parameter astring. There are three logic

the following function, hasFourHs is supposed to return to True if there are at least 4 'H's in the parameter astring. There are three logic errors in the code. Explain what each error is,then show how to fix the function so it works as intended.

def hasFourhs(astring):

count = 0

for ch in astring:

if astring == 'H':

count = count +1

if count < 4:

return True

else:

return False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!