0
0
Data Analysis Pythondata~15 mins

String cleaning (strip, lower, replace) in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
String cleaning (strip, lower, replace)
📖 Scenario: You work in a small online store. You receive customer feedback with messy text data. The text has extra spaces, mixed uppercase and lowercase letters, and some unwanted characters.Cleaning this text helps you analyze customer opinions better.
🎯 Goal: Clean a list of customer feedback strings by removing extra spaces, converting all letters to lowercase, and replacing unwanted characters.
📋 What You'll Learn
Create a list of feedback strings with exact given values
Create a variable for the unwanted character to replace
Use string methods strip(), lower(), and replace() to clean each feedback
Print the cleaned list of feedback strings
💡 Why This Matters
🌍 Real World
Cleaning text data is important in customer feedback analysis, social media monitoring, and preparing data for machine learning.
💼 Career
Data analysts and data scientists often clean messy text data before analysis or building models.
Progress0 / 4 steps
1
Create the feedback list
Create a list called feedback with these exact strings: ' Great product! ', 'Loved it!!', 'Not good...', ' Could be better ', 'Worst experience!!!'
Data Analysis Python
Hint

Use square brackets [] to create a list and include the exact strings with quotes.

2
Set the unwanted character
Create a variable called unwanted_char and set it to the exclamation mark character '!'
Data Analysis Python
Hint

Use single quotes to assign the exclamation mark character to unwanted_char.

3
Clean the feedback strings
Create a new list called cleaned_feedback using a list comprehension. For each string f in feedback, apply strip(), then lower(), then replace all unwanted_char with an empty string ''.
Data Analysis Python
Hint

Use a list comprehension with for f in feedback. Chain the string methods in order: strip(), lower(), then replace().

4
Print the cleaned feedback
Print the variable cleaned_feedback to display the cleaned list of feedback strings.
Data Analysis Python
Hint

Use print(cleaned_feedback) to show the cleaned list.