+ 1

List[int] in python

https://code.sololearn.com/czAIgGgL4jka/?ref=app if List[int] doesn't restrict the list to have only integers, what else does it do?

28th May 2022, 8:54 PM
Harsha S
Harsha S - avatar
5 Respostas
+ 5
isinstance() or type() If I'm correct isinstance() returns also True for subclasses. Type() not. https://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-JUMP_LINK__&&__python__&&__JUMP_LINK
28th May 2022, 9:14 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
It is a type annotation, that hints the user how to provide input. IT DOES NOT DO TYPE-CHECKING.
28th May 2022, 9:01 PM
Lisa
Lisa - avatar
0
Lisa is there any inbuilt way to do type-checking?
28th May 2022, 9:03 PM
Harsha S
Harsha S - avatar
0
List=[Aman,saurav,Aman] Print(list)
29th May 2022, 6:10 AM
ARYAN RAJ