← Back to challenges

Prefixes vs. Suffixes

PythonHardstringsregexvalidation

Instructions

Create two functions: is_prefix(word, prefix-) and is_suffix(word, -suffix).

  1. is_prefix should return True if it begins with the prefix argument.
  2. is_suffix should return True if it ends with the suffix argument.

Otherwise return False.

Examples

is_prefix("automation", "auto-") ➞ True

is_suffix("arachnophobia", "-phobia") ➞ True

is_prefix("retrospect", "sub-") ➞ False

is_suffix("vocation", "-logy") ➞ False

Notes

The prefix and suffix arguments have dashes - in them.

python3
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Human, Cat and Dog Years πŸ§‘πŸ»πŸ±πŸΆ β†’