I am starting out practicing python and came across this little code on leetcode:
def maxProfit(self, prices: List[int]) -> int:
Could someone please explain what the colon after prices does and what does List[int]
and ->
do?
I've just used a colon to slice lists/strings and denote the start of a code block indentation.
Reading online I realized that prices : List[int]
means that price is the argument name and the expression means that prices should be a list of integers and the return type of the function should be an integer.
Can someone tell me if this is correct or would like to expand on it?