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. (

Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵

Similar questions: