What does Optional[int] mean in a type hint in Python?
-
A
Only int
-
B
Optional integer parameter name
-
C
int or str
-
D
int or None
Correct answer
Correct answer
D. int or None
5 views
Explanation
Optional[X] is shorthand for Union[X, None].
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ