Why does my compiler say invalid syntax then highlight...?
7stud
bbxx789_05ss at yahoo.com
Mon Mar 10 23:51:44 EDT 2008
On Mar 10, 9:44 pm, Nathan Pinno <MadComputer... at gmail.com> wrote:
> Why does my compiler say invalid syntax and then highlight the
> quotation marks in the following code:
>
> # This program is to find primes.
> primes = []
> import math
> import gmpy
> while 1:
> run = int(raw_input("Do you want to calculate primes? 1 = yes and
> 2 = no. "))
> if run == 1:
> y = int(raw_input("What number do you want to use as the final
> number to calculate with? "))
> x = int(raw_input("What number do you want to start
> calculating primes from? "))
> while x < 2:
> print "Number must be at least 2 for math reasons."
> else:
> while x < y:
> prime = math.cos(gmpy.pi(0) * gmpy.fac((x-1)) / x)
> if prime < 0:
> primes.append(x)
> else:
> print x " is not prime. " # highlights the final "
> here
> x = x + 1
> print primes
> elif run == 2:
> break
> else:
> print "Sorry, not a choice. Please enter your choice again."
> print "Goodbye."
>
> How do I fix such an invalid syntax?
>
> TIA,
> Nathan Pinno
Try running this:
input = raw_input("Hello
world.")
More information about the Python-list
mailing list