4

In order to indicate that an argument is a list one can use:

def fun(words:list):
    code...

How can I indicate that an argument should be a list of lists? All I can think about is doing something like this:

def fun(words:(list,list)):
    code...

Would that be understandable?

  • 1
    list[list[str]] ? [type-hinting-a-collection-of-a-specified-type](https://stackoverflow.com/questions/24853923/type-hinting-a-collection-of-a-specified-type) – Patrick Artner Sep 21 '21 at 09:54

1 Answers1

5

You could use the typing module:

from typing import List

def fun(l: List[list]):
    code...
U13-Forward
  • 69,221
  • 14
  • 89
  • 114