Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

9.5. The Accumulator Pattern¶


def num_characters(string):
  total = 0
  for character in string:
    total += 1
  return total

original_string = "The quick brown rhino jumped over the extremely lazy fox."
print(f"The numbers of characters in the original string using `len` is {len(original_string)}.")
print(f"The numbers of characters in the original string using `num_characters` is {num_characters(original_string)}.")

Source by w3programmers.org #
 
PREVIOUS NEXT
Tagged: #The #Accumulator
ADD COMMENT
Topic
Name
4+6 =