mardi 19 février 2019

my program that calculates if number is prime or not isn't displaying result in conditional [duplicate]

This question already has an answer here:

def prime():
    input_ = input("Enter a number.")
    return input_
    for number in (2, input_):
        if a % number  == 0:
            return "It's not prime."
        else:
            return "It's prime."


prime()

Okay so I am doing a homework assignment where I need to calculate if a number is prime or not. I am trying to take a user input, store it / return it, and then feed that into a for loop. When I run it, I literally get prompted for the number but nothing else. It doesn't return either of the conditional bodies "It's not prime" or "It's prime". Like if you run it and type in 5, you get NOTHING.

Aucun commentaire:

Enregistrer un commentaire