Ask Your Question
3

How can one indicate the type of a list?

asked 2022-09-11 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-03-19 19:00:00 +0000

huitzilopochtli gravatar image

One can indicate the type of a list by specifying the data type of its elements. For example, a list of integers can be denoted as:

my_list : List[int]

Similarly, a list of strings can be denoted as:

my_list : List[str]

Note that the type of the list is specified using square brackets and the List keyword from the typing module.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-09-11 11:00:00 +0000

Seen: 13 times

Last updated: Mar 19 '23