为什么这是语法错误?我该如何解决它?
class Queue:
#Queue is basicliy a List:
def __init__(self):
self.queue = []
#add to the top of the list (the left side)
def Enqueue(self, num):
if isinstance(num, int):
self.queue.append(num)
#remove from the top of the list and return it to user
def Dequeue(self):
return self.queue.pop(0)
#this function gets inputs from user, and adds them to queue,
#until it gets 0.
def addToQueue(queue, num):
num = input()
while num != 0:
queue.Enqueue(num)
num = input()
交互模式(与>>>
提示)一次只接受一个语句。您已输入两个要同时处理的内容。
输入类定义后,请务必添加extra空行,以便交互式提示知道您已完成。一旦系统提示您>>>
,您就会知道它已准备好进行函数定义。
你的代码的其余部分看起来不错。快乐计算:-)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)