numbers = [2 , 5 , 10]
for n in range[1,20]:
if n in numbers:
continue
print (n)
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
C:\Python34\python.exe "F:/google drive/3d projects/python/untitled/0001.py"
Traceback (most recent call last):
File "F:/google drive/3d projects/python/untitled/0001.py", line 2, in <module>
for n in range[1,20]:
TypeError: 'type' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
寻找答案,但没有发现它是新的python所以不要生气,如果这是一个愚蠢的Qustion奇怪的事情这个代码正好在youtube的教程上使用它的工作我使用pycharm我的python应用程序有任何错误或者ide
嗨我得到这个错误
TypeError: attack() missing 1 required positional argument: 'self'
Run Code Online (Sandbox Code Playgroud)
这是我的代码
class Enemmy :
life = 3
self = ""
def attack(self):
print ("ouch!!!!")
self.life -= 1
def checkLife(self):
if self.life <= 0 :
print ("dead")
else:
print (self.life)
enemy=Enemmy
enemy.attack()
Run Code Online (Sandbox Code Playgroud)
我检查并查看大多数地方说我忘了自我在def攻击或我需要做一个obj把我的类使用python 3.4与py魅力我实际上从教程得到这个代码,我不知道我的是什么错误