Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Python
#1
All,

  I'd really appreciate some help here.  I'm trying to learn Python from a book and in one section they put the function you see below.  So I decided I'd go "off book" and try to make up a simple little program on my own.  From what I can read in the book this should work but I keep getting a syntax error after this part

if (checkIfPrime) == False:
with the colon highlighted. 

I've tried all kinds of permutations with no luck and I asked a friend at work (NOT a programmer but kinda like me) and he wasn't helpful either.

Any advice will be appreciated,

Thanks

Paul




def checkIfPrime(number):
    for x in range (2, number):
        if (number%x == 0):
            return False
    return True

number = int (input ("What number would you like to check to see if it's a prime number?")
             

if (checkIfPrime) == False:
    print ("The number ", number ," is not a Prime number.")
else:
    print ("Congratulations!  The number ", number ," is a Prime number.")
Reply


Messages In This Thread
New to Python - by pmauer456 - Nov-30-2016, 07:25 AM
RE: New to Python - by metulburr - Nov-30-2016, 07:37 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020