import sys
def count_letters_loop(my_neat_thing: str) -> int:
size: int = 0
for letter in my_neat_thing:
size = size + 1
return size
def count_words_loop(sentence: str) -> int:
words: int = 0
# Use strip() to get rid of extraneous spaces
for letter in sentence.strip():
if letter == ' ':
words += 1
# Ensure to count the final word in the sentence.
words += 1
return words
def count_words_easy(sentence: str) -> int:
wordlist: list[str] = sentence.strip().split(' ')
length: int = len(wordlist)
return length
def main() -> None:
inputstring = sys.stdin.read()
print(inputstring)
length: int = count_letters_loop(inputstring)
print(f'length: {length}')
python_length = len(inputstring)
print(f'Python thinks it is: {python_length}')
word_count: int = count_words_loop(inputstring)
print(f'Word count: {word_count}')
builtin_count: int = count_words_easy(inputstring)
print(f'Word count with builtin: {builtin_count}')
with_underscores: str = inputstring.replace(' ', '_')
print(f'Spaces replaced: {with_underscores}')
if __name__ == '__main__':
main()