[
    {
        "role": "user",
        "content": "when%20doing%20type%20annotations%20in%20python%20like%20def%20age(n%3Afloat)%2C%20do%20we%20put%20space%20between%20%3A%20and%20type%3F%20or%20no%20space%3F"
    },
    {
        "role": "assistant",
        "content": "According to PEP 8 (the official Python style guide), when using type annotations like `def age(n: float)`, you should **not** put a space before the colon, but **do** put a space after it. Here's what it says:\n\n- There should be **no space before** the colon in an annotation.  \n  Example: `def age(n: float)` is correct; `def age(n : float)` is not. ([peps.python.org](https://peps.python.org/pep-0008/?utm_source=openai))  \n- Annotations should have a **single space after** the colon. ([peps.python.org](https://peps.python.org/pep-0008/?utm_source=openai))\n\nSo for your example:\n\n```python\ndef age(n: float):\n    ...\n```\n\nis the recommended style.\n\nIf you also have a default value with an annotation, PEP 8 adds that the equals sign should have spaces around it:\n\n```python\ndef func(x: int = 42):\n    ...\n```\n\nIn contrast, for unannotated parameters with default values, the equals sign should **not** have spaces:\n\n```python\ndef func(x=42):\n    ...\n```\n\nBut that part is separate from your question about space around the colon. ([peps.python.org](https://peps.python.org/pep-0008/?utm_source=openai))\n\nIf you like, I can also show how popular tools like Black or Flake8 enforce this to match PEP 8."
    }
]