Can anyone explain this code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone explain this code.

def h(x:str,n:str)-> str: return h.__annotations__ print(h('a','b')['m']) can anyone explain me that how this function works.

30th Apr 2018, 5:23 PM
Maninder $ingh
Maninder $ingh - avatar
1 Answer
+ 3
Function h has 2 parameters, x and n. x and n are both strings. When executed h looks at all parameters of h and returns a dictionary. The keys of the dict are the parameter names, and 'return' for the return annotation, if provided. Note: I had to remove ['m'] in order for the program to execute properly.
30th Apr 2018, 6:34 PM
Johannes
Johannes - avatar