Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Exercise nr. 11 from practicepython.org
- def get_int(input_text="Enter a number: "):
- while True:
- try:
- return int(input(input_text))
- break
- except ValueError:
- print("Use a valid number!")
- def is_priem(getal):
- l = list(range(1,getal+1))
- if len([div for div in l if getal%div == 0]) == 2:
- print("%d is a prime"%getal)
- else:
- print("%d is not a prime"%getal)
- def try_again():
- while True:
- inp=input("Do u want to try again? (y/n): " )
- if (c:= inp.lower()) == "n" or c=="no" :
- return False
- break
- elif c == "y" or c =="yes":
- return True
- break
- else:
- print("I'm not sure what you mean.. please answer with yes or no")
- cont=True
- while cont == True:
- is_priem(get_int())
- cont=try_again()
- print("Goodbye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement