Check the number of letters in a sentence

 sentence = input("Enter a sentence: ")

letters_count = 0 for char in sentence: if char.isalpha(): letters_count += 1 print("Number of letters:", letters_count) This program prompts the user to enter a sentence. It then iterates over each character in the sentence. If a character is an alphabetic letter (using the `isalpha()` method), it increments the `letters_count` variable. Finally, it prints the total number of letters in the sentence.

Comments

Popular posts from this blog

Ecommerce website

Yes, Python is an object-oriented programming (OOP) language, but it is also a multi-paradigm language

Your task is to find the missing number.