write a function call character_thing (string, character) that takes in a string and a character. The function will return the number of times the character appears in the string.
please be in python
Python code:
#defining character_thing function
def character_thing(string,character):
#initializing count as 0
count=0
#looping each character in string
for i in string:
#checking if it is the required character
if(i==character):
#incrementing count
count+=1
#returnining count
return count
#calling character_thing function for a sample string and character
and printing the result
print(character_thing("hii","i"))
Screenshot:
Output:
Get Answers For Free
Most questions answered within 1 hours.