+ 2

What's with this code?

The exercise consist of taking a text as 1st input and a letter as second then calculating the percentage of the letter in the text. I wrote this but the code is not working. Please I need help. x = input() y = input() a = len(x) b = x.count(y) c = b/a print(int(c)*100)

29th Sep 2021, 7:32 AM
Sobi Mohammed
Sobi Mohammed - avatar
2 Respostas
+ 3
b/a is lower than 1. When you convert that to int the result is 0.
29th Sep 2021, 7:35 AM
Simon Sauter
Simon Sauter - avatar
+ 2
Thank you
29th Sep 2021, 7:36 AM
Sobi Mohammed
Sobi Mohammed - avatar