← Back to challenges

Hashes and Pluses

PythonMediumstringsloopsregex

Instructions

Create a function that returns the number of hashes and pluses in a string.

Examples

hash_plus_count("###+") ➞ [3, 1]

hash_plus_count("##+++#") ➞ [3, 3]

hash_plus_count("#+++#+#++#") ➞ [4, 6]

hash_plus_count("") ➞ [0, 0]

Notes

  • Return [0, 0] for an empty string.
  • Return in the order of [hashes, pluses].
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Next Element in Arithmetic Sequence