0
Is my annotations are correct ? What is correct way or syntax to create annotations in functions ?
# This is my first annotation code in python. #I don't know completely how to put annotation in function. def f(ham_or_spam: str, eggs: list=[]) -> int: print("Annotations:", f.__annotations__) if ham_or_spam == 'spam' and eggs: return 'This is a spam' elif ham_or_spam == 'ham' and eggs: return 'This is a ham' else: return 'This is not a ' + ham_or_spam print(f('spam',True)) print(f('spam'))
1 Resposta
+ 1
I'm not quite sure what this function is about, but it seems to return a string, so shouldn't it be "-> str"?