Question: Write a python function char _ ind which accepts two parameters, a string and a character ( char ) , which in Python will also

Write a python function char_ind which accepts two parameters, a string and a character (char), which in Python will also have the datatype string. The function should return a list with the indices at which the character appears in the string. If the character does not appear in the string, the function should return an empty list.
Function Name: char_ind
Parameters: string, string
Return Value: list
Example: if I pass the parameters 'Hello World!' and 'l', the return value should be [2,3,9]. However, if I pass the parameters 'Welcome' and 'a', the return value should be []

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!