Question #883

Which statement is wrong about the code snippet below?
def my_function(my_var: str) -> str:
    return 2 * my_var

Even if we give an hint to Python that the function is expected to return a string with -> str , it doesn't mean that the function has to return a string. In this case, if an integer is passed to the function as an argument, the function will return another integer without exceptions. (python.org/dev/peps/pep-0484)


Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: