+ 1

Why this code is giving "No Output " message when I run it in code playground?

def count_char(text, char): n= 0 for c in text: if c == char: n += 1 else: n=0 return n count_char("aha","a")

16th Jul 2017, 10:00 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
6 Answers
+ 8
there's no print statement
16th Jul 2017, 10:03 AM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
+ 2
ya the function has returned value.. but how will you see it.? it won't be displayed.. so you need to have the print statement.. write... print(count_char("aha","a"));
17th Jul 2017, 5:17 AM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
0
i am really crazy. thanks anyways
16th Jul 2017, 10:51 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
0
no print statement ,šŸ˜‚šŸ˜‚šŸ˜‚šŸ˜‚šŸ˜‚šŸ˜‚
17th Jul 2017, 5:14 AM
Aryan Singh
0
but return to krna chahiye na??
17th Jul 2017, 5:15 AM
Aryan Singh
0
oh yes i'm also crazy thank you
17th Jul 2017, 5:19 AM
Aryan Singh