This content originally appeared on DEV Community and was authored by Mahmoud EL-kariouny
Type check
level of challenge = 2/10
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.
My solution
def only_ints(num_1, num_2):
if type(num_1) == int and type(num_2) == int:
return True
else:
return False
print(only_ints("tito", 2))
Another solution
def only_ints(a, b):
return type(a) == int and type(b) == int
This content originally appeared on DEV Community and was authored by Mahmoud EL-kariouny
Mahmoud EL-kariouny | Sciencx (2021-09-08T15:36:01+00:00) Python challenge_4. Retrieved from https://www.scien.cx/2021/09/08/python-challenge_4/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.