How To Print Return Value Of Method In Python?
class Queue(): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def Enqueue(self,item): return self.items.insert
Solution 1:
If you want to know what's goingto be returned, you need to save it locally, print what you saved, then return what you saved. Something like:
x = Q.Dequeue()
print(x)
return x
Solution 2:
Your code works for me, when you change Q.Dequeue()
by print Q.Dequeue()
.
Better python would be:
from collections import deque
defhotspot(names, num):
queue = deque(reversed(names))
whilelen(queue)>1:
queue.rotate(num)
print queue.pop()
return queue.pop()
print hotspot(['A','B','C','D','E','F'], 7)
Post a Comment for "How To Print Return Value Of Method In Python?"