变量x总是显示为语法错误。它表示要生成的质数的个数
x=501
while x<1 or x>500:
NoNos=int(input("Number of Prime Numbers"))
if x<1:
print("The number has to be greater than 1")
if x>500:
print("The number has to be lesser than 500")
PrimeNo=2
PrimeNos=[]
While not x==0:
if PrimeNo==2:
PrimeNos=PrimeNos+[PrimeNo]
x=x-1
PrimeNo=PrimeNo+1
continue
for divisor in the range (2,PrimeNo-1):
if not PrimeNo%divisor=0:
x=x-1
PrimeNos=PrimeNos+[PrimeNo]
print(PrimeNos)
我修正了你代码中的一些错误
==============================================================================
这是Python中的一个bug。插入符号应指向“While”中的大写字母“W”。你必须用所有小写字母拼写“while”。在
你还有一些其他的错误:
^{pr2}$这里的插入符号应该指向“the”,它应该被删除。在
这一次插入符号是在正确的地方='必须是'=='。在
在我做了所有这些更改之后,你的程序仍然不能工作,但是剩下的问题似乎不是语法问题。在
(我把http://bugs.python.org/issue23518放错了插入符号上。)
相关问题 更多 >
编程相关推荐