Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Validate a discount code format

Python data engineering interview problem. Difficulty: beginner. Pattern: Strings. About 10 minutes. Part of the Pro drill bank.

Checkout accepts a discount code string. Fraud wants a strict format check before the code is sent to billing, not a fuzzy 'looks ok' guess.

Return whether a discount code matches the required format.

Requirements

  • The function is a yes/no validator.
  • Follow the format rules implied by the tests (length, charset, pattern).

Constraints

  • Do not throw; return a boolean.

Examples

Input: valid_discount_code('SAVE-100') Output: True This input follows the stated rules and produces this output.

Topics: lakebench, python, functions.

More Python interview questions · All interview problems · Learn data engineering

beginner

Validate a discount code format

Interview-style drill: Write a function that checks whether a discount code matches a required pattern.

Return whether a discount code matches the required format.