CoursesCSS StudioExamplesGATECompaniesPrepMentora
Programs/Logic building/Phase 5 - Category 1: Basic String Handling

5 / 10

Next
1. Length of String2. Reverse String3. Convert to Uppercase4. Convert to Lowercase5. Count Vowels6. Count Consonants7. Count Words8. Check Palindrome String9. Remove All Spaces10. Count Each Character

Phase 5 - Category 1: Basic String Handling

  1. 01Length of String
  2. 02Reverse String
  3. 03Convert to Uppercase
  4. 04Convert to Lowercase
  5. 05Count Vowels
  6. 06Count Consonants
  7. 07Count Words
  8. 08Check Palindrome String
  9. 09Remove All Spaces
  10. 10Count Each Character

Count Vowels

Count number of vowels in string.

BeginnerPhase 5 - Category 1: Basic String HandlingExample 5 of 10
count-vowels.py
1# Take string input
2s = input("Enter a string: ")
3
4# Count vowels
5vowels = "aeiouAEIOU"
6count = 0
7for char in s:
8 if char in vowels:
9 count += 1
10
11print(f"Number of vowels: {count}")

Output

Enter a string: Hello
Number of vowels: 2

What's going on

Check each character if it's a vowel.

Key Concepts:

Define vowel string
Check if character in vowels
Count matches

🔗Related Content

  • 📖

    Phase 5 - Learn Concepts

    Review Phase 5 concepts and explanations

  • 📝

    Phase 5 - Quiz

    Test your Phase 5 understanding with quiz questions

  • 💻

    Phase 5 - All Practice Problems

    Explore all practice problems for Phase 5

  • 🎓

    Master Your Logic Building - Complete Course

    Browse all phases and tutorials

  • 🧠

    Logic Building Overview

    Learn about the complete logic building curriculum

PreviousConvert to LowercaseNextCount Consonants

On this page

CodeOutputExplanation
Up nextCount Consonants
Schoolabe

Learn, Practice, Ace Coding

ExamplesCompaniesTutorialsCSS StudioDSA VisualizersQuizInterview PrepMentoraCareer QuestGATE CS prepGATE CS 2027 study planJob ReadyInternships
AboutContactCareersAffiliate programBlog
DocumentationAPI ReferenceCommunitySupport
Privacy PolicyTermsRefund PolicyCookie Policy

© 2026 Schoolabe