If an object is a certain type, return its length

I want to make a module function called ‘len’ that detects if the object is a table or a string and gets its length. I do know about the hashtag operator and the string.len() function, I want to combine them into one function.

Current Code:

function pylua.len(object)
	if type(object) == {} then
		return #object
	else if type(object) == "string" then
		return string.len(object)
	else
		return print("DataTypeError: Given object is not a string or a table.")
	end
	end
end

However, it returns the “DataTypeError” when the object is a table.
I have also used the typeof function, but it does the same thing.
How can I do this?

Try printing the objects type/typeof and see what it outputs.

I replaced ‘{}’ with ‘table’ because ‘table’ was the output. Still doesn’t work.

What is objects value? Is it nil?

Nevermind. The type was table but it didn’t work. I just put the word into a string and it now works.