0
Text analyser
def count_char(text, char): count = 0 for i in text: if i == char: count += 1 return count text = input("Enter a filename: ") print(text) print(count_char(text, "a")) #count_char("mahalakshmi", 'a') why output doesnt come or this line, but the previous lines gives output
2 Respostas
+ 6
You preceded the whole line with a hash sign (#) which means a comment in Python. Basically, the interpreter ignores this line treating it as a comment only.
+ 4
Also, your function doesn't contain a print function, so if you want to print the returned value, you need to say
print(count_char("mahalakshmi", 'a'))