How to indicate that an argument is a list of lists
Asked Answered
B

1

5
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?

Bridesmaid answered 21/9, 2021 at 9:51 Comment(1)
list[list[str]] ? type-hinting-a-collection-of-a-specified-typeWoodrowwoodruff
H
9

You could use the typing module:

from typing import List

def fun(l: List[list]):
    code...
Height answered 21/9, 2021 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.