Skip to the content.

Tools and Setup Emoji Hack

Emojis

def count_character_types(input_string):
    total_letters = 0
    total_numbers = 0
    total_spaces = 0

    for char in input_string:
        if char.isalpha():
            total_letters += 1
        elif char.isdigit():
            total_numbers += 1
        elif char.isspace():
            total_spaces += 1

    return total_letters, total_numbers, total_spaces


if __name__ == "__main__":
    user_input = input("Enter a string: ")
    letters, numbers, spaces = count_character_types(user_input)

    print(f"Total letters: {letters}")
    print(f"Total numbers: {numbers}")
    print(f"Total spaces: {spaces}")
Total letters: 3
Total numbers: 3
Total spaces: 3