Python in 30 Days Day 4
Day four was more string work. It was focused on manipulating strings and doing some built in methods to build some analytics.
Challenge:
You’re processing user-submitted restaurant reviews. Real user input is messy — inconsistent casing, extra spaces, typos in structure. Write a program that:
- Starts with this list of raw reviews exactly as given:
raw_reviews = [
" great burger, loved it! ",
"FRIES WERE COLD. bad experience. ",
" the milkshake was amazing. will return.",
"salad was okay. nothing special. ",
"BROWNIE IS A MUST TRY!! "
]
- Writes a function
clean_review(review)that:
- Strips leading/trailing whitespace
- Converts to sentence case (first letter capitalized, rest lowercase — look up which method does this in one step)
- Returns the cleaned string
- Uses a list comprehension to apply
clean_reviewto every review, storing results incleaned_reviews - Writes a function
analyze_reviews(reviews)that returns a dictionary containing:
"total": count of reviews"positive": count of reviews containing words like “great”, “amazing”, “loved”, “must”, “will return”"avg_length": average character length of the reviews (rounded to nearest whole number)
- Prints the cleaned reviews and the analysis dictionary cleanly
Things to figure out: how to check if any of several words appear in a string, and how to calculate an average from a list.

