0
0
Pythonprogramming~15 mins

String values and text handling in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
String values and text handling
📖 Scenario: You are working on a simple program that manages a list of book titles in a small library. You want to practice handling string values and text operations in Python.
🎯 Goal: Build a program that stores book titles, sets a keyword to search for, finds all titles containing that keyword, and prints the matching titles.
📋 What You'll Learn
Create a list of book titles with exact given values
Create a keyword variable with a specific string
Use a list comprehension to find titles containing the keyword
Print the list of matching titles
💡 Why This Matters
🌍 Real World
Managing and searching text data like book titles, product names, or messages is common in many software applications.
💼 Career
Understanding string handling and filtering is important for roles in data processing, software development, and quality assurance.
Progress0 / 4 steps
1
Create the list of book titles
Create a list called books with these exact titles: 'The Great Gatsby', 'To Kill a Mockingbird', 'Great Expectations', 'The Catcher in the Rye', and 'The Grapes of Wrath'.
Python
Need a hint?

Use square brackets [] to create a list and separate each title with commas.

2
Set the keyword to search
Create a variable called keyword and set it to the string 'Great'.
Python
Need a hint?

Use simple assignment with the exact string 'Great'.

3
Find titles containing the keyword
Use a list comprehension to create a new list called matching_books that includes only the titles from books that contain the keyword string.
Python
Need a hint?

Use [title for title in books if keyword in title] to filter titles containing the keyword.

4
Print the matching titles
Print the matching_books list to show the titles that contain the keyword.
Python
Need a hint?

Use print(matching_books) to display the list.