class Solution:
def display(self,head):
current = head
while current:
print(current.data,end=' ')
current = current.next
您好,我有一些困难,了解上述while循环,据我所知,你需要有一个while循环的条件,所以:Python的While循环语法
while (stuff) == True:
但上面的代码有:
while current:
这是一样的:
while current == head:
感谢
你似乎混淆while循环之上的语句的含义。它与循环无关,或者它是有条件的。相反,它将变量'head'复制到变量'current'。然后当前被转换为布尔值并检查它是'真实的'[Mariusz Jamro](http://stackoverflow.com/users/342473/mariusz-jamro)的[answer](http://stackoverflow.com/ a/38230275/2465194)如下解释。 – rtmh