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 StringBeginnerReverse a string entered by the user.Open example →
  2. 02Check Palindrome StringBeginnerCheck whether a given string is a palindrome (ignoring case and spaces).Open example →
  3. 03Count Vowels in StringBeginnerCount the number of vowels in a given string.Open example →
  4. 04Count Consonants in StringBeginnerCount the number of consonants (alphabetic non-vowels) in a string.Open example →
  5. 05Count Digits in StringBeginnerCount how many digit characters appear in a string.Open example →
  6. 06Remove Special CharactersBeginnerRemove all non-alphanumeric characters from a string.Open example →
  7. 07Remove WhitespaceBeginnerRemove all whitespace characters from a string.Open example →
  8. 08Find SubstringBeginnerCheck if a substring exists within a string and find its index.Open example →
  9. 09Replace SubstringBeginnerReplace all occurrences of a substring with another substring.Open example →
  10. 10Character FrequencyBeginnerCount the frequency of each character in a string.Open example →
  11. 11Capitalize First Letter of Each WordBeginnerCapitalize the first letter of each word in a sentence.Open example →
  12. 12Convert String to Title CaseBeginnerSame as .title() on the previous page, printed in one line. McDonald still becomes Mcdonald.Open example →
  13. 13Sort String CharactersBeginnerSort the characters of a string in ascending order.Open example →
  14. 14Find Longest WordBeginnerFind the longest word in a sentence.Open example →
  15. 15Find Shortest WordBeginnerFind the shortest word in a sentence.Open example →
  16. 16String CompressionIntermediateImplement a simple run-length encoding (RLE) compression for strings.Open example →
  17. 17String RotationIntermediateCheck whether one string is a rotation of another.Open example →
  18. 18Anagram CheckBeginnerCheck whether two strings are anagrams of each other.Open example →
  19. 19Split and Join StringsBeginnerSplit a sentence into words and join them with a given delimiter.Open example →
  20. 20Count Words in StringBeginnerCount the number of words in a sentence.Open example →
  21. 21Extract Numbers from StringIntermediateExtract all integer numbers from a mixed string.Open example →
  22. 22Validate Email Using RegexIntermediateA toy regex. It accepts test@example.com. It also accepts garbage that looks vaguely like an email.Open example →
  23. 23Validate Phone Number Using RegexIntermediateValidate a simple phone number format using regular expressions.Open example →
  24. 24Check PangramIntermediateCheck whether a sentence is a pangram (contains every letter of the alphabet at least once).Open example →
  25. 25Convert snake_case to camelCaseIntermediateConvert a snake_case string to camelCase.Open example →