Camel case to snake case
Write a function that converts camelCase input to snake_case while handling acronyms and numbers correctly.
Longest word in a sentence
Write a function that returns the longest word from a sentence, with first-occurrence tie-breaking.
Extract Digits Only
Given a string that may contain letters, symbols, and whitespace, extract all digits in order and return them as an integer.
Longest Word Finder
Write a function that extracts alphabetic words from a string and returns the longest one, with ties broken by earliest position.
Extract digits from string
Write a function that extracts all digit characters from a given string, preserving their original order.
Kebab Case Converter
Implement a function that converts any string to kebab-case, handling spaces, underscores, camelCase, and punctuation.
Expand compressed string
Implement a function that expands run-length encoded strings (e.g., 'a3b2' → 'aaabb').
Roman to Integer
Convert a valid Roman numeral string to an integer using standard rules.
Safe Command Executor
Implement emulate_run that simulates running a command list and returns output and exit code.
Stack Trace Sanitizer
Implement a function that rewrites traceback file paths to basenames only.
Extract Hashtags
Extract unique hashtags from a given text string in the order they appear.
Extract mentions
Extract unique @mentions from a string, respecting email-like patterns and punctuation.
Validate time format
Check whether a given string is a valid 24-hour time in HH:MM format.
Parse Log Line
Write a function that parses a log line and returns a dictionary with timestamp, level, and message.
Remove HTML tags
Remove all HTML tags from a string to extract clean text.
Extract Quoted Strings
Write a function that extracts the text inside every double-quoted substring from a given string.
Split on camelCase
Given a camelCase string, split it into words at uppercase letters and return them as lowercase words.
Extract domain from URL
Extract the domain (hostname without port or www) from a given URL string.
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.
Replace template variables
Implement a function that replaces {{variable}} placeholders in a string using a dictionary, leaving unknown placeholders intact.
Showing 22 challenges · easy · 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.