0 out of 464 challenges solved
Write a Python function `count_characters` that takes a single string as input and returns the total number of characters in the string.
#### Example Usage
```python [main.nopy]
print(count_characters("hello")) # Output: 5
print(count_characters("Python")) # Output: 6
print(count_characters("")) # Output: 0
```
#### Requirements
- The function should handle empty strings and return `0` for them.
- The function should count all characters, including spaces and special characters.def count_characters(input_string):
"""
Count the total number of characters in the given string.
Args:
input_string (str): The string to count characters in.
Returns:
int: The total number of characters in the string.
"""
# Initialize a counter variable
total_characters = 0
# Iterate through each character in the string
# Increment the counter for each character
# Return the total count
return total_characters