Strip Leading Zeros
Write a function that strips leading zeros from a string representing a non-negative integer.
Parse key=value pairs
Implement a parser that converts a space-separated 'key=value' string into a Python dictionary, supporting quoted values.
Find all numbers in text
Write a function that extracts all standalone integers from a text string using regular expressions.
Extract file extensions
Implement a function that extracts the extension from a filename according to standard rules.
Validate username format
Implement a function that validates a username according to length, allowed characters, and no consecutive underscores.
Replace template variables
Implement a function that replaces {{variable}} placeholders in a string using a dictionary, leaving unknown placeholders intact.
Hamming Distance
Implement a function that computes the Hamming distance between two strings of equal length.
Hex encode decode
Write hex_encode and hex_decode to convert between hex strings and integer byte values.
ROT13 Transform
Implement ROT13, a letter substitution cipher that rotates the alphabet by 13 positions.
Caesar Cipher Decrypt
Implement a function that decrypts a Caesar cipher by shifting letters back by a given number.
Simplify Path
Implement a function that simplifies a Unix-style absolute file path to its canonical form.
Basic Calculator III
Implement a recursive descent parser to evaluate a fully parenthesized arithmetic expression with +, -, *, / and parentheses.
Minimum Remove Valid Parentheses
Given a string with parentheses and letters, remove the fewest parentheses to make it valid.
Remove Duplicate Letters
Implement a function that removes duplicate characters from a string while preserving the order of their first occurrence.
Custom Sort String
Given a string s and an order string, reorder s so that characters that appear in order come first in that order, and all other characters are appended in stable original order.
Change directory manager
Implement a function that processes `cd` commands and returns the resulting absolute path.
Parse URL components
Write parse_url that splits a URL into its standard components with defaults for missing parts.
Parse HTTP Status Line
Write a function that parses a well-formed HTTP status line into its three components.
Parse key-value lines
Parse structured key-value lines into a dictionary with support for quoted values and escaped characters.
Parse markdown headers
Write a function that parses markdown headers and returns their levels and texts.
Parse bullet list
Parse a markdown-style bullet list and return the list of item texts, stripping bullet markers and trimming surrounding whitespace.
Parse numbered list
Take a string containing a numbered list and return a clean list of the item texts.
Decode base64 string
Write a function that decodes a base64 string to its original UTF-8 text without using the base64 module.
Parse Version SemVer
Write a function that parses a semantic version string into its numeric components.
Showing 73–96 of 108 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.