Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using python and while loop only, Write code that takes a string and a list of c

ID: 3722382 • Letter: U

Question

Using python and while loop only,

Write code that takes a string and a list of characters from the user, and returns the number of occurrences of any of the characters in the string. Below are some examples:
‘hello’ and [‘l’] will return 2
‘hello’ and [‘l’,’o’] will return 3
‘hello’ and [‘q’] will return 0
You may not use any built-in functions/methods besides len().

Template:

def countChars(string, list):

    string = string
    chars = list
    
    
    #YOUR CODE GOES HERE (indented)

    return 0
    #END YOUR CODE

Write code that takes a string and a list of characters from the user, and returns the number of occurrences of any of the characters in the string. Below are some examples:
‘hello’ and [‘l’] will return 2
‘hello’ and [‘l’,’o’] will return 3
‘hello’ and [‘q’] will return 0
You may not use any built-in functions/methods besides len().

Template:

def countChars(string, list):

    string = string
    chars = list
    
    
    #YOUR CODE GOES HERE (indented)

    return 0
    #END YOUR CODE

Explanation / Answer

def countChars(string, list): string = string chars = list count = 0 i = 0 while i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote