Reputation: 11
I try to write a function using match and case keyword.
complex_obj = [1,23,4]
match type(complex_obj):
case list:
iter_obj = complex_obj
case dict:
iter_obj = complex_obj.items()
But I got this error.
case list: ^^^^ SyntaxError: name capture 'list' makes remaining patterns unreachable
How do I fix it?
I expect to get iterable object based on the type.
Upvotes: 0
Views: 22