x_=[range(1,1000000)]
def pr(x_):
for a in x_:
# is type(a) int ??
if a==2 or a==3 :
x_[a-1]=0
continue
for j in range(2,a):
if(a%j==0):
x_[a-1]=0
break
pr(x_)
TypeError: unsupported operand type(s) for %: 'list' and 'int' | very interesting case?
x_=[range(1,1000000)]
This will cause x_
to be [[1, 2, 3, ... 999999]]
. Note the two brackets. It is a doubly nested list, so a
will be a list and not an int. If you just want a
to be an int and x_
to be [1, 2, 3, ... 999999]
, try
x_ = range(1,1000000)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.