Auto-Moderate Product Reviews

Medium ⏱ 12 min 58% acceptance ★★★★★ 4.7
Write moderate(review) for dicts with text, rating, verified_purchase, account_age_days. Reject ('reject') when the text is under 10 chars or contains any banned word ('fake', 'scam', 'spam' — case-insensitive). Hold ('hold') 1-2 star ratings from accounts under 7 days old. Everything else: 'approve'.

Examples

Example 1
Input
moderate({'text': 'Total scam do not buy', 'rating': 1, 'verified_purchase': True, 'account_age_days': 400})
Output
'reject'
Explanation

The banned word rule fires first.

Example 2
Input
moderate({'text': 'Decent quality for the price', 'rating': 2, 'account_age_days': 3, 'verified_purchase': False})
Output
'hold'
Explanation

Low rating + brand-new account.

Constraints

  • Rules apply in the stated priority.
  • Word check is substring, case-insensitive.

Topics

Business Logicmoderation rules

Companies

AmazonFlipkartNykaa

Hints

Hint 1

Guard clauses in order: reject, hold, approve.

Hint 2

any(w in text.lower() for w in banned).

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.