Skip to main content
← CoursesFastAPI ProductionModule 1 · FastAPI BasicsPydantic v2 — your contract layerpredict3 / 101
💬 Discuss🧪 Playground+75 XP
Task
📝 **Predict** the result: ```python from pydantic import BaseModel, Field class Order(BaseModel): qty: int = Field(..., gt=0) try: Order(qty=-3) except Exception as e: print("error" if "greater" in str(e).lower() else "ok") ```

Keep going

🔮 Predict the output

Read the code carefully

from pydantic import BaseModel, Field

class Order(BaseModel):
    qty: int = Field(..., gt=0)

try:
    Order(qty=-3)
except Exception as e:
    print("error" if "greater" in str(e).lower() else "ok")

What will the program print? Write here:

📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…