bpo-46059: Clarify pattern-matching example in "control flow" docs (GH-30079)

The "Color" example in the pattern-matching section of the "control flow" documentation is not immediately runnable, leading to confusion.

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
This commit is contained in:
Alex Waygood 2021-12-14 15:04:29 +00:00 committed by GitHub
parent 74821b3053
commit 1cbb88736c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -395,9 +395,11 @@ Several other key features of this statement:
from enum import Enum from enum import Enum
class Color(Enum): class Color(Enum):
RED = 0 RED = 'red'
GREEN = 1 GREEN = 'green'
BLUE = 2 BLUE = 'blue'
color = Color(input("Enter your choice of 'red', 'blue' or 'green': "))
match color: match color:
case Color.RED: case Color.RED: