Type Conversion in Custom Function (parameters)

A built-in function allows type conversion.
eg: print(type(str(1234)))

But a custom function returns Syntax-Error.
eg:
def func(str(n)): print(type(n)) func(1234)

Can anyone please help understand why ? More importantly if we can incorporate type-conversion within Function parameter list, it would save some lines of code.

Thank you.

1 Like

Try the following instead:

print(type(str(n)))

Exactly!
My question was why def func(str(n)): would be an error?

Because that is how the syntax of a function in Python was made.