Playwright + Python · Lesson 3 of 37
Module 3: Strings
Your task
Implement clean_and_extract_order(text):
Write it in the editor, then press Check answer (Ctrl + Enter).
raw_text = " Order #49281 Confirmed! "
# Cleaning and extracting:
cleaned = raw_text.strip() # "Order #49281 Confirmed!"
is_order = cleaned.startswith("Order #")
order_id = cleaned.split("#")[1].split()[0] # "49281"
# Formatting with f-strings:
env = "staging"
login_url = f"https://{env}.targetqa.com/login"Every web page contains text: button labels, order IDs, and error banners. In this lesson, you will master Python string methods like strip(), split(), replace(), and f-strings to format and parse test data. Let's master strings!
Part of the Playwright + Python course (Playwright with Python). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
f-strings (Python 3.6+) are faster, more readable, and evaluate expressions directly inside {expression}.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___