def singleNumber(self, nums: List[int]) -> int: code example
Example 1: nums: List[int] in python function
from typing import List
Vector = List[float]
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]
new_vector = scale(2.0, [1.0, -4.2, 5.4])
Example 2: nums: List[int] in python function
"""
In the function greeting, the argument name is expected to be of type str and the
return type str. Subtypes are accepted as arguments.
"""
def greeting(name: str) -> str:
return 'Hello ' + name