MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __str__

Method __str__

data_structures/queues/linked_queue.py:70–81  ·  view source on GitHub ↗

>>> queue = LinkedQueue() >>> for i in range(1, 4): ... queue.put(i) >>> queue.put("Python") >>> queue.put(3.14) >>> queue.put(True) >>> str(queue) '1 <- 2 <- 3 <- Python <- 3.14 <- True'

(self)

Source from the content-addressed store, hash-verified

68 return len(tuple(iter(self)))
69
70 def __str__(self) -> str:
71 """
72 >>> queue = LinkedQueue()
73 >>> for i in range(1, 4):
74 ... queue.put(i)
75 >>> queue.put("Python")
76 >>> queue.put(3.14)
77 >>> queue.put(True)
78 >>> str(queue)
79 '1 <- 2 <- 3 <- Python <- 3.14 <- True'
80 """
81 return " <- ".join(str(item) for item in self)
82
83 def is_empty(self) -> bool:
84 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected