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

10th Jun 2018, 7:07 AM
S Mahalakshmi
2 Respuestas
+ 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.
10th Jun 2018, 7:09 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 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'))
10th Jun 2018, 7:17 AM
David Ashton
David Ashton - avatar