python snippet: check if object is a string and if it ends with '.zip'
- User
python snippet: check if object is a string and if it ends with '.zip'
Assistant
Here's a simple Python snippet to check if an object is a string and ends with '.zip':
pythondef is_zip_file(obj): return isinstance(obj, str) and obj.endswith('.zip')You can call it like this:
python>>> is_zip_file('test.zip') True >>> is_zip_file(1234) False >>> is_zip_file('test.txt') False
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.