0
What is the difference between?
def func(self, lst: List[int]) -> int: # body def func(self, lst): # body
6 Antworten
+ 2
The upper method uses *type annotation*, the bottom one doesn't
+ 4
Type annotations are just a hint for the user – it does not do any type casting! Therefore it does not influence how the code is executed.
Here's a brief article, how the annotations can be used:
https://towardsdatascience.com/type-annotations-in-JUMP_LINK__&&__python__&&__JUMP_LINK-d90990b172dc
0
The top one's list parameter takes explicitly a list of integers and also explicitly returns an integer
0
The bottom is the same,
These are two different solutions in the same problem on a problem solving website
0
Is this considered a difference?
0
Thanks for help