Jump to content

I Just Don't Understand

- - - - -

  • Please log in to reply
2 replies to this topic

#1
AIGuy

AIGuy

    Learning Programmer

  • Members
  • PipPipPip
  • 64 posts
Python was recommended to me by a friend so i decided to take a whack at it. I did a hello world and then decided to try this out.
numberToStartAt = input('Input a number to start at: ')

print(findNextPrime(numberToStartAt))

input('Press any key to continue...')


def findNextPrime(numberToLookAfter):

    currentNumber = numberToLookAfter

    while(not len(getFactors(currentNumber) == 2):

        currentNumber = currentNumber + 1

    return currnetNumber



def getFactors(numberToFactor):

    factorList = []

    for x in range(1,numberToFactor/2,1):

          for x2 in range(numberToFactor, numberToFactor/2,-1):

              if x * x2 == numberToFactor:

                  factorList.append([x,x2])

    return factorList
I keep getting a syntax error about line 7.Based on all the example code I've seen. This ought to work. What am I doing wrong.

PS
This is python 3.2

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You appear to be missing some right parentheses.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
AIGuy

AIGuy

    Learning Programmer

  • Members
  • PipPipPip
  • 64 posts
Holy cow!!! Can't believe I missed that!

Thank you! Sorry for the trouble.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users