0

I am new to Python and I have the next questions in the below code line. Please help.

def method(self, a : dict) -> list:
  • 1st question: what does it mean to declare a: dict?
  • 2nd question: What does that arrow (-> list) means/indicates/represents?

To be honest I just have an idea about the first thing (a: dict), but I need the complete picture about how that way of writing that kind of python method works.

Thanks in advance.

Christian
  • 29
  • 6

2 Answers2

3

So these are type hints.

a : dict is saying that a should be of type dict

and -> list is saying the function will return the type list

The documentation for this can be found here

Rashid 'Lee' Ibrahim
  • 1,357
  • 1
  • 9
  • 21
2
  1. a : dict means the argument 'a' for the function is of dictionary type.
  2. `-> list' means that this function will return a list variable.
underhood31
  • 115
  • 7