How can modify this to do atleast 2 test cases for each function using doctest? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How can modify this to do atleast 2 test cases for each function using doctest?

def mystring(string): def my_split(string,seperator=""): lst=[ ] for i in string: if seperator==i: continue lst1=lst.append(i) print(lst) my_split(string,seperator="") char=input("Character needed to count : ") ''' Count the number of occurrences of a character in a given string >>> count_char("animalplanet", 'a') 3 >>> count_char("animalplanet", 's') 0 ''' def count_char(string, char): counter=string.count(char) print(counter) count_char(string, char) '''Count the number of occurrences of a character in a given string ''' index=int(input("Index of the character needed to remove : ")) def remove_char(string, index): string = string[:index] + string[index + 1:] print(string) remove_char(string, index)

8th Sep 2021, 12:46 PM
Ushani Harshila
0 Antworten