Skip to content

Instantly share code, notes, and snippets.

@willy-r
Created August 25, 2020 18:49
Show Gist options
  • Save willy-r/9df38e4fc5a76c44cad10fb46fb5f732 to your computer and use it in GitHub Desktop.
Save willy-r/9df38e4fc5a76c44cad10fb46fb5f732 to your computer and use it in GitHub Desktop.
Given a string s and a character c, return the number of occurrences of c in s.
def num_chars(s: str, c: str):
"""Returns the number of occurrences of c in s."""
return s.lower().count(c.lower())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment