Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsPython

String Programs

reverse, palindrome, split, regex. Strings are where beginners leak hours.

25 programs · open one, then the next

The matching chapter is Day 4: Strings and String Methods in the Python course. For a short check, try the Python quiz (300 questions). Every topic is listed on Python exercises.

Start with Reverse a String
  1. 01Reverse a StringBeginnerWalk Python text backward with s[::-1] without editing the original. A beginner slicing lesson includes empty strings and limits of reversing Unicode symbols.Open example →
  2. 02Check Palindrome StringBeginnerIgnore whitespace and case before checking a Python text palindrome. Beginners trace normalization and learn why punctuation or empty text changes the answer.Open example →
  3. 03Count Vowels in StringBeginnerCount vowel occurrences, not just unique letters, with Python sum and a generator. A beginner string scan includes both cases and states its English vowel rule.Open example →
  4. 04Count Consonants in StringBeginnerExclude punctuation before counting Python consonants. Beginners combine isalpha with vowel exclusion and see where the English-only rule misclassifies text.Open example →
  5. 05Count Digits in StringBeginnerMeasure digit characters rather than whole numbers in Python text. A beginner isdigit scan explains signs, decimal points, repeated digits, and Unicode surprises.Open example →
  6. 06Remove Special CharactersBeginnerKeep letters, numbers, and whitespace in Python text. Beginners use join and notice why deleting punctuation can merge words instead of separating them.Open example →
  7. 07Remove WhitespaceBeginnerRemove Python whitespace from the middle as well as the ends of text. A beginner filter compares isspace with strip and shows why neighboring words merge.Open example →
  8. 08Find SubstringBeginnerA Python match at index zero is still a match. This beginner str.find walkthrough checks -1 explicitly and explains empty targets and case-sensitive positions.Open example →
  9. 09Replace SubstringBeginnerReplace Python substring matches and keep the returned text. Beginners inspect immutable strings, non-overlapping matches, absent targets, and empty replacements.Open example →
  10. 10Character FrequencyBeginnerBuild a Python character frequency table one dictionary update at a time. Beginner steps explain get defaults, repeated keys, and quoted labels for whitespace.Open example →
  11. 11Capitalize First Letter of Each WordBeginnerStore Python title-case output before printing it. A beginner string-method lesson covers lowercased remaining letters and the surprises in names and apostrophes.Open example →
  12. 12Convert String to Title CaseBeginnerPrint Python title-case text directly without a result variable. Beginners compare expression styles and see why acronyms and names need more careful formatting.Open example →
  13. 13Sort String CharactersBeginnerSort Python characters into a list, then join them back into text. New programmers examine duplicates, uppercase ordering, spaces, and unchanged source strings.Open example →
  14. 14Find Longest WordBeginnerChoose a sentence’s longest token with Python max and key=len. A beginner text exercise checks blank input and explains punctuation and first-winner ties.Open example →
  15. 15Find Shortest WordBeginnerFind the shortest Python sentence token by length rather than alphabet. First-year practice uses split, an empty-list guard, and a predictable rule for ties.Open example →
  16. 16String CompressionIntermediateEncode aaabbc as a3b2c1 with a Python run counter. Beginners flush the final group and learn why a simple run-length format is not always smaller or reversible.Open example →
  17. 17String RotationIntermediatePicture a circular cut to test Python string rotations with doubled text. A beginner membership trick explains equal lengths, zero shifts, and empty strings.Open example →
  18. 18Anagram CheckBeginnerCompare Python anagrams without losing repeated-letter counts. Beginners normalize spaces and case, sort characters, and distinguish this rule from rotation.Open example →
  19. 19Split and Join StringsBeginnerChoose your own separator for Python words using split and join. A beginner walkthrough explains collapsed whitespace, empty delimiters, and retained punctuation.Open example →
  20. 20Count Words in StringBeginnerDecide what counts as a word before using Python split and len. Beginner examples handle blank text, repeated whitespace, and hyphenated tokens without guessing.Open example →
  21. 21Extract Numbers from StringIntermediateExtract digit runs from Python text with a small regex. Beginners keep matched strings and leading zeroes while seeing why decimals and signs need a richer rule.Open example →
  22. 22Validate Email Using RegexIntermediateRead a Python email regex piece by piece as a beginner string exercise. Understand raw strings and literal dots without treating a match as mailbox verification.Open example →
  23. 23Validate Phone Number Using RegexIntermediateMatch an optional plus and 10–15 digits with Python regex. A beginner format check explains bounded repetition and why a match does not establish a real number.Open example →
  24. 24Check PangramIntermediateRequire all 26 English letters with a Python subset test. Beginners use sets for presence, ignore repeated letters, and allow extras without weakening the rule.Open example →
  25. 25Convert snake_case to camelCaseIntermediateTurn hello_world into helloWorld with Python split and capitalization. A beginner naming exercise traces empty segments, underscores, and changed acronyms.Open example →