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
Get step-by-step solutions from verified subject matter experts
