Reverse a string
Return the characters of the string in reverse order.
Run-length encoding
Compress consecutive identical characters, e.g. 'aaabbc' → 'a3b2c1'.
Remove punctuation
Write a function that removes all ASCII punctuation characters from a string.
Is pangram
Write a function that determines whether a given string is a pangram, ignoring case and non-letter characters.
Repeat each character n times
Given a string s and an integer n, return a new string where each character of s is repeated n times consecutively.
Normalize quotes
Replace all typographic quote characters with straight ASCII quotes.
Interleave Two Strings
Given two strings s1 and s2, return a new string that interleaves them character by character, starting with s1.
Sort characters alphabetically
Sort all characters in a string alphabetically and return the sorted string.
Is pangram?
Implement is_pangram(s) to return True if the string contains every letter from 'a' to 'z' at least once, ignoring case and non-alphabetic characters.
Remove Duplicates from String
Given a string, return a new string with each character that repeats consecutively reduced to a single occurrence.
Mask email address
Given an email address, return a masked version that hides everything but the first and last character of the local part and the domain.
Extract digits from string
Write a function that extracts all digit characters from a given string, preserving their original order.
Is isogram?
Write a function that checks whether a given word is an isogram, ignoring letter case and only considering alphabetic characters.
Compress Consecutive Chars
Write a function that compresses a string by replacing runs of identical characters with the character followed by the count.
Sort characters in string
Write a function that sorts the characters in a string and returns the sorted string.
Most Common Character
Return the character that appears most frequently in a string, breaking ties by earliest occurrence.
Isomorphic Strings Check
Given two strings, check if they are isomorphic by verifying a one-to-one character mapping.
Validate username format
Implement a function that validates a username according to length, allowed characters, and no consecutive underscores.
Hamming Distance
Implement a function that computes the Hamming distance between two strings of equal length.
Showing 19 challenges · Strings & Text
Strings & Text — Python coding challenges
What you will find here
This page lists strings & text challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.