Write a function named only_ints that takes two parameters. Your function should return True if both parameters are integers, and False otherwise.
For example, calling only_ints(1, 2) should return True, while calling only_ints("a", 1) should return False.
ChatGPT
ChatGPT
Here's a Python function named only_ints that checks if both parameters are integers:
python
Copy code
def only_ints(param1, param2):
return isinstance(param1, int) and isinstance(param2, int)
# Example usage:
print(only_ints(1, 2)) # Output: True
print(only_ints("a", 1)) # Output: False
Copy and Save
Share
Ask Copilot
This function uses the isinstance() function to check if both parameters are of type int. If both are integers, it returns True; otherwise, it returns False.