Skip to content

fix: correct Lesson 6.1 grading regex syntax error#110

Open
gn00295120 wants to merge 1 commit intoanthropics:masterfrom
gn00295120:fix/lesson-6.1-grading-syntax-103
Open

fix: correct Lesson 6.1 grading regex syntax error#110
gn00295120 wants to merge 1 commit intoanthropics:masterfrom
gn00295120:fix/lesson-6.1-grading-syntax-103

Conversation

@gn00295120
Copy link

Fixes #103

Description

Fixed Python syntax error in Exercise 6.1 grading code. The REGEX_CATEGORIES
dictionary used regular expressions with escaped backslashes, but Python's string
parser was trying to interpret the escape sequences before passing them to the
regex engine, causing a syntax error.

Changes

  • Added raw string prefix (r) to all regex patterns in REGEX_CATEGORIES
  • This ensures backslashes are passed literally to the regex parser

Technical Details

Before: "A\) P" (Python tries to parse ) as invalid escape)
After: r"A\) P" (Python treats backslash literally)

Testing

  • Verified regex patterns compile correctly with raw strings
  • Confirmed this matches the solution suggested in the issue

Fixed Python syntax error in Exercise 6.1 by using raw strings (r prefix)
for REGEX_CATEGORIES. The backslashes in regex patterns need to be escaped
properly for Python's string parser before being passed to regex engine.

Changes:
- Added r prefix to all regex strings in REGEX_CATEGORIES
- Fixes: SyntaxError when Python tries to parse the escape sequences

Before: "A\) P"  (Python tries to parse \) as invalid escape sequence)
After:  r"A\) P"  (Python treats backslash literally, passes to regex)

Fixes anthropics#103

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 15, 2026 03:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Python syntax error in Exercise 6.1 of the Precognition tutorial where regex patterns used invalid escape sequences. The fix adds raw string prefixes (r) to the regex patterns in the REGEX_CATEGORIES dictionary, ensuring backslashes are passed literally to the regex engine rather than being interpreted as escape sequences by Python's string parser.

Changes:

  • Added raw string prefix r to all four regex patterns in REGEX_CATEGORIES dictionary
  • Added explanatory comment documenting the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lesson 6.1 grading syntax error

2 participants