Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created February 17, 2020 19:04
Show Gist options
  • Save mayankdawar/2729dbebb8bd972b20607699f1129801 to your computer and use it in GitHub Desktop.
Save mayankdawar/2729dbebb8bd972b20607699f1129801 to your computer and use it in GitHub Desktop.
Write code to count the number of characters in original_str using the accumulation pattern and assign the answer to a variable num_chars. Do NOT use the len function to solve the problem (if you use it while you are working on this problem, comment it out afterward!)
original_str = "The quick brown rhino jumped over the extremely lazy fox."
counter = 0 #intializing a counter varialble
for i in original_str:
counter += 1 #adding 1 after every iteration
num_chars = counter #getting the result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment