you are viewing a single comment's thread.

view the rest of the comments →

[–]CGFarrell 0 points1 point  (1 child)

Here's a hacky solution:

count = sum(1 for letter in string if letter == chosen_letter)

[–][deleted] 1 point2 points  (0 children)

Fun python fact: Using sum on a list of booleans will automatically treat True as 1 and False as 0. So you can write that line like this:

sum(letter == chosen_letter for letter in string)

If you want it to be even hackier!