What is the difference between? | Sololearn: Learn to code for FREE!


What is the difference between?

def func(self, lst: List[int]) -> int: # body def func(self, lst): # body

9/20/2021 3:59:06 PM

Mahmoud ayman

6 Answers

New Answer


The upper method uses *type annotation*, the bottom one doesn't


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-python-d90990b172dc


The top one's list parameter takes explicitly a list of integers and also explicitly returns an integer


The bottom is the same, These are two different solutions in the same problem on a problem solving website


Is this considered a difference?


Thanks for help