Practice Arena

Python Coding Challenges

Write real Python in the browser. Instant feedback. From beginner to expert.

467 challenges 330 easy 120 medium 17 hard
Strings & Text easy

Reverse a string

Return the characters of the string in reverse order.

strings slicing
+5 pts 5m
Strings & Text easy

Palindrome check

Return True if the string reads the same forwards and backwards (ignoring case and non-alphanumeric).

strings two-pointer
+8 pts 8m
Strings & Text easy

Count vowels

Count the number of vowels (a, e, i, o, u) in a string (case-insensitive).

strings counting
+5 pts 5m
Strings & Text easy

Title case converter

Return the string with each word capitalised.

strings split
+5 pts 5m
Strings & Text easy

Anagram check

Return True if two strings are anagrams of each other.

strings sorting counter
+10 pts 10m
Strings & Text easy

Strip and Collapse Whitespace

Write a function that strips leading/trailing whitespace and collapses inner runs of whitespace to single spaces.

strings whitespace normalization
+10 pts 15m
Strings & Text easy

Snake case to camel case

Implement a function that converts snake_case strings to camelCase.

strings case-conversion text-processing
+10 pts 10m
Strings & Text easy

Camel case to snake case

Write a function that converts camelCase input to snake_case while handling acronyms and numbers correctly.

strings case-conversion parsing
+10 pts 15m
Strings & Text easy

Remove punctuation

Write a function that removes all ASCII punctuation characters from a string.

strings punctuation cleaning
+10 pts 10m
Strings & Text easy

Is pangram

Write a function that determines whether a given string is a pangram, ignoring case and non-letter characters.

strings sets algorithm
+8 pts 12m
Strings & Text easy

Caesar Cipher Shift

Implement a function to apply a Caesar cipher shift to a string, preserving case and ignoring non-letters.

strings ascii cipher
+10 pts 15m
Strings & Text easy

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.

strings join comprehension
+8 pts 10m
Strings & Text easy

Longest word in a sentence

Write a function that returns the longest word from a sentence, with first-occurrence tie-breaking.

strings parsing split
+8 pts 10m
Strings & Text easy

Replace vowels with stars

Write a function that replaces every vowel in a given string with an asterisk.

strings transformation vowels
+10 pts 10m
Strings & Text easy

Is isogram

Implement a function that determines whether a string is an isogram (no repeated letters, case-insensitive).

strings case-insensitive validation
+10 pts 10m
Strings & Text easy

Extract Digits Only

Given a string that may contain letters, symbols, and whitespace, extract all digits in order and return them as an integer.

strings digits parsing
+5 pts 5m
Strings & Text easy

Kebab Case a Phrase

Implement a function that converts a phrase into lowercase kebab-case, handling spaces, punctuation, and camelCase.

strings case-conversion regex
+10 pts 15m
Strings & Text easy

Normalize quotes

Replace all typographic quote characters with straight ASCII quotes.

strings replacement unicode
+10 pts 12m
Strings & Text easy

Find all indexes of a substring

Write a function that returns a list of all starting indexes where a substring appears in a string, including overlapping occurrences.

substring string searching
+10 pts 15m
Strings & Text easy

Remove Consecutive Duplicate Letters

Implement a function that removes consecutive duplicate letters from a string, keeping only one occurrence of each run.

strings loops manipulation
+10 pts 15m
Strings & Text easy

Interleave Two Strings

Given two strings s1 and s2, return a new string that interleaves them character by character, starting with s1.

strings merging loops
+8 pts 10m
Strings & Text easy

Is rotation of another string

Write a function to determine if one string is a rotation of another string.

strings rotation membership
+10 pts 15m
Strings & Text easy

Sort characters alphabetically

Sort all characters in a string alphabetically and return the sorted string.

sorting string manipulation
+5 pts 5m
Strings & Text easy

Initials from a Full Name

Return the uppercase initials of each word in a given full name.

strings splitting uppercase
+8 pts 10m
Strings & Text easy

Count words in a sentence

Implement a function to count words in a sentence, ignoring extra whitespace and handling empty strings.

strings split counting
+10 pts 10m
Strings & Text easy

Center a string in a width

Write a function that centers a string within a specified width by adding spaces on both sides.

strings padding formatting
+8 pts 10m
Strings & Text easy

Caesar Cipher Shift

Write a function that shifts letters in a string by a given amount, preserving case and ignoring non-letters.

caesar string cipher
+8 pts 10m
Strings & Text easy

Reverse Words in a Sentence

Reverse the order of words in a sentence while preserving single spaces between words.

strings split reverse
+10 pts 15m
Strings & Text easy

Count consonants

Write a function that counts the number of consonant letters in a string.

strings counting loops
+10 pts 10m
Strings & Text easy

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.

strings set validation
+8 pts 10m
Strings & Text easy

Remove Duplicates from String

Given a string, return a new string with each character that repeats consecutively reduced to a single occurrence.

strings loop filter
+8 pts 10m
Strings & Text easy

Longest Word Finder

Write a function that extracts alphabetic words from a string and returns the longest one, with ties broken by earliest position.

strings parsing max
+10 pts 10m
Strings & Text easy

Abbreviate Name

Create a function that takes a full name and returns an abbreviated version with initials and the last name.

strings formatting split
+10 pts 15m
Strings & Text easy

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.

strings masking validation
+8 pts 10m
Strings & Text easy

Extract digits from string

Write a function that extracts all digit characters from a given string, preserving their original order.

strings digits parsing
+6 pts 8m
Strings & Text easy

Replace Spaces with Dashes

Write a function that replaces every space in a string with a dash.

strings replace manipulation
+5 pts 5m
Strings & Text easy

Capitalize First Letter

Write a function that capitalizes the first letter of each word in a string.

string capitalization title
+8 pts 10m
Strings & Text easy

Snake case converter

Implement a function that converts a string to snake_case according to given rules.

strings snake_case formatting
+10 pts 15m
Strings & Text easy

Camel Case Converter

Write a function that converts a space-separated phrase into lower camelCase.

strings casing manipulation
+8 pts 10m
Strings & Text easy

Kebab Case Converter

Implement a function that converts any string to kebab-case, handling spaces, underscores, camelCase, and punctuation.

strings case-conversion parsing
+8 pts 15m
Strings & Text easy

Count Syllables (Simple)

Count syllables in a word by counting groups of consecutive vowels (a, e, i, o, u).

strings vowels counting
+10 pts 15m
Strings & Text easy

Is isogram?

Write a function that checks whether a given word is an isogram, ignoring letter case and only considering alphabetic characters.

strings case-insensitive set
+8 pts 12m
Strings & Text easy

Rotate String Right

Implement a function that rotates a given string to the right by a specified number of positions, handling shifts larger than the string length.

strings rotation slicing
+8 pts 10m
Strings & Text easy

Compress Consecutive Chars

Write a function that compresses a string by replacing runs of identical characters with the character followed by the count.

string run-length compression
+8 pts 12m
Strings & Text easy

Expand compressed string

Implement a function that expands run-length encoded strings (e.g., 'a3b2' → 'aaabb').

strings parsing run-length-encoding
+10 pts 15m
Strings & Text easy

Find substring index

Implement a function that returns the starting index of the first occurrence of a substring using only basic string indexing and slicing.

string search index
+10 pts 15m
Strings & Text easy

Count Substrings

Implement a function that counts non-overlapping occurrences of a substring in a given string.

strings counting substrings
+10 pts 15m
Strings & Text easy

Sort characters in string

Write a function that sorts the characters in a string and returns the sorted string.

sorting string character
+8 pts 10m
Strings & Text easy

Most Common Character

Return the character that appears most frequently in a string, breaking ties by earliest occurrence.

strings counting dictionary
+10 pts 15m
Strings & Text easy

Roman to Integer

Convert a valid Roman numeral string to an integer using standard rules.

roman string integer
+10 pts 15m
Strings & Text easy

Isomorphic Strings Check

Given two strings, check if they are isomorphic by verifying a one-to-one character mapping.

strings mapping hash-map
+10 pts 15m
Strings & Text easy

Index of First Occurrence

Implement a function that finds the starting index of a substring within a string, returning -1 when absent.

strings search index
+8 pts 12m
Strings & Text easy

Safe Command Executor

Implement emulate_run that simulates running a command list and returns output and exit code.

string-parsing simulation lists
+8 pts 10m
Strings & Text easy

Error message formatter

Write a function that constructs a formatted error message from a code, an optional context, and a fallback message.

formatting strings function
+10 pts 15m
Strings & Text easy

Stack Trace Sanitizer

Implement a function that rewrites traceback file paths to basenames only.

strings regex parsing
+8 pts 12m
Strings & Text easy

Extract Hashtags

Extract unique hashtags from a given text string in the order they appear.

strings parsing hashtags
+10 pts 15m
Strings & Text easy

Extract mentions

Extract unique @mentions from a string, respecting email-like patterns and punctuation.

strings parsing sets
+10 pts 15m
Strings & Text easy

Validate time format

Check whether a given string is a valid 24-hour time in HH:MM format.

strings validation time
+10 pts 15m
Strings & Text easy

Parse Log Line

Write a function that parses a log line and returns a dictionary with timestamp, level, and message.

string-parsing split strip
+10 pts 15m
Strings & Text easy

Replace multiple spaces

Implement a function that replaces every sequence of spaces with a single space.

strings whitespace normalization
+8 pts 10m
Strings & Text easy

Remove HTML tags

Remove all HTML tags from a string to extract clean text.

html string parsing
+10 pts 15m
Strings & Text easy

Extract Quoted Strings

Write a function that extracts the text inside every double-quoted substring from a given string.

strings parsing quotes
+8 pts 12m
Strings & Text easy

Split on camelCase

Given a camelCase string, split it into words at uppercase letters and return them as lowercase words.

strings parsing camelcase
+8 pts 10m
Strings & Text easy

Extract domain from URL

Extract the domain (hostname without port or www) from a given URL string.

url parsing strings
+8 pts 12m
Strings & Text easy

Normalize Whitespace

Write a function that normalizes any whitespace in a string to single spaces and trims the ends.

strings whitespace split-join
+5 pts 10m
Strings & Text easy

Strip Leading Zeros

Write a function that strips leading zeros from a string representing a non-negative integer.

strings strip lstrip
+5 pts 5m
Strings & Text easy

Parse key=value pairs

Implement a parser that converts a space-separated 'key=value' string into a Python dictionary, supporting quoted values.

parsing strings dictionaries
+8 pts 10m
Strings & Text easy

Find all numbers in text

Write a function that extracts all standalone integers from a text string using regular expressions.

regex parsing numbers
+8 pts 12m
Strings & Text easy

Extract file extensions

Implement a function that extracts the extension from a filename according to standard rules.

strings parsing file-paths
+8 pts 10m
Strings & Text easy

Validate username format

Implement a function that validates a username according to length, allowed characters, and no consecutive underscores.

strings validation returns
+8 pts 12m
Strings & Text easy

Replace template variables

Implement a function that replaces {{variable}} placeholders in a string using a dictionary, leaving unknown placeholders intact.

string-manipulation parsing template
+10 pts 15m
Strings & Text easy

Hamming Distance

Implement a function that computes the Hamming distance between two strings of equal length.

strings character-comparison distance
+10 pts 15m

Showing 72 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.