Nov-05-2022, 01:49 PM
okay, i put it like this (at the beginning) and it works, but why didn't it work in the previous version ? (in the previous reply),
import sys user_input = int(input("choose a number: ")) if user_input < 2: print("this number is not prime") elif user_input > 0: for x in range(2, user_input-1): if user_input % x != 0: continue elif user_input % x == 0: sys.exit("number is not prime") print("number is prime") elif user_input == 2: print("the number is prime")