Question: Can You help me to find and fix error in code please? ### this is my code but given me an error please help. def

Can You help me to find and fix error in code please?

### this is my code but given me an error please help.

def count_sub_strings(string, substring): # Initialize count and start to 0 count = 0 start = 0 # Search through the string till # we reach the end of it while start < len(string): # Check if a substring is present from # 'start' position till the end pos = string.find(substring, start) if pos != -1: # If a substring is present, move 'start' to # the next position from start of the substring start = pos + 1 # Increment the count count += 1 else: # If no further substring is present break # return the value of count return count

# Tests %run -i m269_util test_table = [ ['None','abc','def',0], ['One','abc','xabcx',1], ['Two','abc','xabcxabc',2] ] test(count_sub_strings, test_table)

ERRor given :

One FAILED: 0 instead of 1 Two FAILED: 0 instead of 2 Tests finished. 

Above is my adjusted code and below here is Original coce:

# *Write your code solution here* def count_sub_strings(substring: str, main_string: str) -> int: pass # replace pass with your code

# Tests %run -i m269_util test_table = [ ['None','abc','def',0], ['One','abc','xabcx',1], ['Two','abc','xabcxabc',2] ] test(count_sub_strings, test_table)

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 Databases Questions!