Python Strings
Practice Questions
Easy → Medium → Hard
■ Easy Level
1. Take a string as input and print it.
2. Find the length of a string.
3. Print the first and last character of a string.
4. Convert a string to uppercase.
5. Convert a string to lowercase.
6. Count the number of times a character appears in a string.
7. Check whether a string is empty or not.
8. Reverse a string.
9. Print the first 3 characters of a string.
10. Print the last 3 characters of a string.
11. Check whether a character exists in a string.
12. Concatenate two strings.
13. Remove leading and trailing spaces.
14. Count the total number of words in a string.
15. Replace one word with another word.
■ Medium Level
1. Check whether a string is a palindrome.
2. Count the number of vowels and consonants.
3. Count the number of spaces in a string.
4. Print each character of a string on a new line.
5. Check whether a string contains any digit.
6. Count the number of uppercase and lowercase letters.
7. Remove all spaces from a string.
8. Find the frequency of each character.
9. Convert a sentence into title case.
10. Find the longest word in a sentence.
11. Reverse each word in a sentence.
12. Find the index of a specific character.
13. Check whether two strings are equal.
14. Remove duplicate characters from a string.
15. Find the most frequently occurring character.
■ Hard Level
1. Check whether two strings are anagrams.
2. Find the first non-repeating character in a string.
3. Compress a string (e.g., aaabbcc → a3b2c2).
4. Implement Run-Length Encoding.
5. Find all duplicate characters in a string.
6. Validate an email address.
7. Validate a password based on given rules.
8. Count the frequency of every word in a paragraph.
9. Find the longest palindrome substring.
10. Check whether one string is a rotation of another.
11. Find the character with the second-highest frequency.
12. Implement a simple text encryption and decryption program.
13. Find all substrings of a string.
14. Find the longest common prefix among multiple strings.
15. Create a mini spell-checker for a given list of words.
■ Mini Projects Using Strings
1. Password Strength Checker
2. Email Validator
3. Username Validator
4. Word Counter
5. Typing Speed Tester
6. Text Encryptor / Decryptor
7. Emoji Converter
8. Hangman Game
9. Chatbot
10. URL Shortener Logic
Python Strings Practice Questions • Happy Coding! ■