Strange syntax error in Python 2.7.3 -


i have decided learn basic programming, , using mit opencourseware class learn in python. 1 of assignments create program generates 1000th prime number starting 0. 1 of first solutions follows:

oddlist = [] odd in range(3, 10000): if odd % 2 != 0:     oddlist.append(odd) else:     continue   primecount = 3 loopholder = true while loopholder == true:  possibleprime in oddlist:     if primecount == 1000:         print possibleprime         loopholder = false     math import *     limit = int(math.sqrt(possibleprime)      primetest in range(2, limit):             testcount = 0             if possibleprime % primetest == 0:                 testcount = testcount + 1                 primecount = primecount                             else:                 continue             if testcount > 0:                 primecount = primecount                 break             else:                 primecount = primecount + 1                 break 

however, when run it, syntax error @ "for primetest in range(2, limit):" , python highlighting colon specifically. realize error result of syntax error somewhere else, can't find it. point out error is?

ps: semantics of code not needed, though appreciated.

you have "while loopholder == true:" without indented block after it. should write "while loopholder:", == true part isn't required. avoid doing import within loop. import statements @ top of file, unless need somewhere else. don't have closing bracket after "limit = int(math.sqrt(possibleprime)".


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -