Python data hide | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python data hide

Я немного не понимаю наверное, но почему в push нет return, а в pop есть? Код взят из урока сокрытия данных https://code.sololearn.com/c0PJIIb9X9f8/?ref=app

9th Jul 2021, 12:47 AM
Ilya Vasilyev
Ilya Vasilyev - avatar
1 Answer
+ 3
Because it does not need to. On the two methods `pop` and `__repr__`, a returned value is needed. Note that list.insert() method does not return any value, it just performs an action which inserts a certain element in an index. On the other hand, list.pop() method removes the last element in the queue (or the first element in queue data structue), and it also return the removed value so the user can see what was removed or "popped". For now, that is not necessary for understanding data hiding. Anyway, if you want to learn more about queue, try the "Python Data Structures" course here in Sololearn. Потому что это не нужно. Для двух методов 'pop' и '__repr__' требуется возвращаемое значение. Обратите внимание, что метод list.insert () не возвращает никакого значения, он просто выполняет действие, которое вставляет определенный элемент в индекс. С другой стороны, метод list.pop () удаляет последний элемент в очереди (или первый элемент в структурировании данных очереди), а также возвращает удаленное знач
9th Jul 2021, 1:57 AM
noteve
noteve - avatar