Python challenge_4

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 Tru…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Python challenge_4." Mahmoud EL-kariouny | Sciencx - Wednesday September 8, 2021, https://www.scien.cx/2021/09/08/python-challenge_4/
HARVARD
Mahmoud EL-kariouny | Sciencx Wednesday September 8, 2021 » Python challenge_4., viewed ,<https://www.scien.cx/2021/09/08/python-challenge_4/>
VANCOUVER
Mahmoud EL-kariouny | Sciencx - » Python challenge_4. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/08/python-challenge_4/
CHICAGO
" » Python challenge_4." Mahmoud EL-kariouny | Sciencx - Accessed . https://www.scien.cx/2021/09/08/python-challenge_4/
IEEE
" » Python challenge_4." Mahmoud EL-kariouny | Sciencx [Online]. Available: https://www.scien.cx/2021/09/08/python-challenge_4/. [Accessed: ]
rf:citation
» Python challenge_4 | Mahmoud EL-kariouny | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.