Ifound the code as follow in python3:
def twoSum(self, nums: List[int], target: int) -> List[int]:
return sum(nums)
As I know for python def
, we only need follow:
def twoSum(self, nums, target):
return sum(nums)
what is the nums: List[int], target: int
and ->List[int]
means? Are those new features of python 3? I never see those.
Thanks,
from typing import List
def twoSum(nums: List[int], target: int) -> List[int]:
print(nums, target)
Link: https://docs.python.org/3/library/typing.html
Note The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.
Link: https://code.visualstudio.com/docs/python/linting
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With