Title case converter
Return the string with each word capitalised.
Longest word in a sentence
Write a function that returns the longest word from a sentence, with first-occurrence tie-breaking.
Replace vowels with stars
Write a function that replaces every vowel in a given string with an asterisk.
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.
Center a string in a width
Write a function that centers a string within a specified width by adding spaces on both sides.
Remove Duplicates from String
Given a string, return a new string with each character that repeats consecutively reduced to a single occurrence.
Longest Word Finder
Write a function that extracts alphabetic words from a string and returns the longest one, with ties broken by earliest position.
Abbreviate Name
Create a function that takes a full name and returns an abbreviated version with initials and the last name.
Replace Spaces with Dashes
Write a function that replaces every space in a string with a dash.
Compress Consecutive Chars
Write a function that compresses a string by replacing runs of identical characters with the character followed by the count.
Index of First Occurrence
Implement a function that finds the starting index of a substring within a string, returning -1 when absent.
Parse Log Line
Write a function that parses a log line and returns a dictionary with timestamp, level, and message.
Replace multiple spaces
Implement a function that replaces every sequence of spaces with a single space.
Extract domain from URL
Extract the domain (hostname without port or www) from a given URL string.
Parse URL components
Write parse_url that splits a URL into its standard components with defaults for missing parts.
Decode base64 string
Write a function that decodes a base64 string to its original UTF-8 text without using the base64 module.
User Friendly Message
Given a raw user input, format it into a single clean sentence with proper sentence case and trimming.
Showing 18 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.