Created
July 30, 2017 10:41
-
-
Save rostyq/02d5584823de4a2593305983a6f09659 to your computer and use it in GitHub Desktop.
Exercise on www.practicepython.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_user_int(msg): | |
''' | |
Return integer from user. | |
:param msg: | |
:return user_input: | |
''' | |
user_input = input(msg) | |
try: | |
user_input = int(user_input) | |
except: | |
print("Something wrong...") | |
return user_input | |
num = get_user_int("Input a number: ") | |
rng = range(1,num + 1) | |
new_rng = [i for i in rng if num % i == 0] | |
if len(new_rng) == 2: | |
print("Entered number is prime.") | |
else: | |
print("Entered number is not prime.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment