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

0

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

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