Return type of Function with Parameters

65 views Asked by At
def add(num1:int,num2:int ) -> str:
    num3 = num1+num2
    return num3
num1 , num2 = 5,6
ans = add(num1,num2)
print(type(ans))
print(f"Addition of {num1} and {num2} is {ans}")

I was expecting to return type(ans) as string class.It is happening when i write 3rd line as return str(num3).In Geeks for geeks(https://www.geeksforgeeks.org/python-functions/) i have seen syntax as def function_name(parameter: data_type) -> return_type: why the code is not returning to string class as i wrote return type as 'str' Is typecasting not possible here?

0

There are 0 answers