Anyone has tested these code on https://docs.python.org/3/tutorial/controlflow.html ?
if there were no "Tab" before "color...", it would prompt:if one "Tab" added, it would prompt:
Code:
from enum import Enumclass Color(Enum): RED = 'red' GREEN = 'green' BLUE = 'blue'color = Color(input("Enter your choice of 'red', 'blue' or 'green': "))match color: case Color.RED: print("I see red!") case Color.GREEN: print("Grass is green") case Color.BLUE: print("I'm feeling the blues :(")Code:
File "<stdin>", line 5 color = Color(input("Enter your choice of 'red', 'blue' or 'green': ")) ^^^^^SyntaxError: invalid syntaxCode:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 5, in ColorNameError: name 'Color' is not definedStatistics: Posted by MianQi2019 — Mon Nov 10, 2025 5:21 am — Replies 1 — Views 48