Python string exercises
Python string problems, from slicing and formatting to parsing text, each checked by tests in your browser.
Beginner
- 2. Say HelloA personal greeting25 XP2 min
- 7. Capitalize WordsGive every word a capital letter35 XP3 min
- 10. Reverse a StringText, back to front40 XP3 min
- 12. Count VowelsHow many vowels hide in the text?45 XP5 min
- 30. Missing LettersWhich letters of the alphabet never show up in this sentence?30 XP6 min
- 33. Reverse the Word OrderRead a sentence back to front, one whole word at a time30 XP5 min
- 34. Caesar CipherSlide every letter along the alphabet to hide a message35 XP8 min
- 202. InitialsA whole name squeezed into a few letters25 XP4 min
- 208. Word CountHow long is this essay, really?25 XP3 min
- 222. Mask an Email AddressShow enough of an email address to recognise it, and no more30 XP5 min
- 227. Snake Case to Camel CaseRename a Python variable for a JavaScript teammate30 XP5 min
- 247. Censor Banned WordsKeep the comments clean without mangling innocent words40 XP8 min
- 256. Title Case With Small WordsMake a book title look the way publishers print it40 XP8 min
Intermediate
- 17. Palindrome CheckDoes it read the same backwards?60 XP6 min
- 53. Longest Common PrefixThe longest beginning that every word in the list agrees on55 XP8 min
- 57. Compress Repeated LettersSqueeze runs of repeated letters, but only when it saves space60 XP10 min
- 65. Roman Numerals to IntegerWhat number is MCMXCIV hiding?60 XP9 min
- 68. Integer to Roman NumeralsWrite any year the way the Romans carved it in stone65 XP10 min
- 94. Rail Fence CipherZigzag a secret message across rails, then read it off row by row75 XP14 min
- 101. Most Frequent WordsFind the words a piece of writing leans on the most80 XP15 min
- 263. Same Letter PatternDo egg and add share a secret shape?55 XP8 min
- 282. Look and Say1, 11, 21, 1211: what comes next?65 XP12 min
- 312. Word WrapFit paragraphs into a narrow column without splitting a word70 XP14 min
- 314. Camel Case to Snake CaseBring Java-style names into Python style, acronyms and all75 XP14 min
Advanced
- 137. Longest Palindromic SubstringSomewhere inside this string is its longest mirror image125 XP25 min
- 155. Number to English WordsSpell out any number the way you would say it aloud140 XP30 min
- 165. Shortest PalindromeAdd as few letters as possible to the front to make it read both ways155 XP30 min
- 345. Replace and Keep the CaseFind and replace that respects SHOUTING, Titles and lowercase115 XP20 min
- 355. Shortest Unique PrefixesHow few letters does it take to tell each word apart?120 XP20 min
- 388. Match the AbbreviationsWhich words could i18n stand for?140 XP30 min
- 409. Find Every OccurrenceFind every place a marker appears in a genome-sized text150 XP30 min
- 430. Longest Repeated SubstringThe longest piece of text that shows up twice175 XP35 min
Expert
- 177. Justify TextLay out words in tidy lines that touch both margins, like a newspaper210 XP40 min
- 195. Glob Pattern MatchingWhich file paths does a pattern full of stars and question marks pick out?260 XP50 min
- 446. Palindrome PairsWhich two words glue together into a palindrome?220 XP45 min
- 467. Line-by-Line DiffWhat changed between two versions of a file?240 XP50 min
Other topics
- Python Basics
- Lists
- Dictionaries and sets
- Loops
- Functions
- Math
- Sorting and searching
- Two pointers
- Sliding window
- Stacks and queues
- Recursion and backtracking
- Dynamic programming
- Greedy
- Graphs
- Trees
- Bit manipulation
- Classes
- Iterators and generators
- Parsing
- Simulation
- Python idioms
- Regular expressions
- Codes and ciphers
- Working with data
- Grids and matrices
- Geometry
- Games and puzzles
- Heaps
- Data structures
Or see every challenge, with study plans, today's challenge and duels.