Kinda newb-ish question

BW Glitch bwglitch at hotpop.com
Thu Dec 11 21:38:14 EST 2003


ChocoboMog123 wrote:

> What's wrong with line 8 in this code?
> x=1
> while 1==1:
I think it would be better as:
  while True:
>     x=x+1
>     y=range(1,x)
>     z=0
>     q=9
>     for count in y:
>         q=x%y
It should be:
          q=x%count
>         if q==0:
>             z=z+1
>     if z<1:
>         print x
> It keeps giving me 
> Traceback (most recent call last):
>   File "C:\Python23\Prime Number.py", line 8, in -toplevel-
>     q=x%y
> TypeError: unsupported operand type(s) for %: 'int' and 'list'
> 
> It's supposed to be a program to print out prime numbers.
> If anyone knows of a program that does this or can write one, can you
> show me the code? Thanks.

As it points out, y is a list.


-- 
Glitch

-----BEGIN TF FAN CODE BLOCK-----
G+++ G1 G2+ BW++++ MW++ BM+ Rid+ Arm-- FR+ FW-
#3 D+ ADA N++ W OQP MUSH- BC- CN++ OM P75
-----END TF FAN CODE BLOCK-----

"So, give us the scoop! What's it actually feel like, bein' a Pred?"
"Like you're three gigabytes of attitude on a two-gig hard drive. No
wonder they got personality problems!"
         -- Cheetor and Rhinox, "Dark Designs"





More information about the Python-list mailing list