0

I stumbled over the following code:

x: int = 1.0

and I wonder: what does it do (and why does it work at all - I expect this to be a SyntaxError)?

The only thing I found out is that the tpye of x is still float, so it is not equivalent to x = int(1.0).

Qaswed
  • 3,179
  • 5
  • 24
  • 41
  • 1
    That's type annotation. Official doc: https://docs.python.org/3/library/typing.html – Andrej Kesely Jul 02 '19 at 07:51
  • 1
    Possible duplicate of [What are variable annotations in Python 3.6?](https://stackoverflow.com/questions/39971929/what-are-variable-annotations-in-python-3-6) – Georgy Jul 02 '19 at 07:53

0 Answers0