Question: from referential_array import build_array class List: def __init__(self,max_capacity=50): self.array=build_array(max_capacity) self.count=0 Implementing append in array based list?I have this class list and I'm trying to implement
from referential_array import build_array
class List:
def __init__(self,max_capacity=50): self.array=build_array(max_capacity) self.count=0
Implementing append in array based list?I have this class list and I'm trying to implement append.This is my referential array.I'm trying to implement append but the console keeps outputting
import ctypes
def build_array(size): """ This function creates an array of references to Python Objects. Args: size (int): A positive integer, the size of the array. Returns: An array of python references with the given size. """ if size <= 0: raise ValueError("Array size should be larger than 0.") if not isinstance(size, int): raise ValueError("Array size should be an integer.") array = (size * ctypes.py_object)() array[:] = size * [None] return array def append(self,item): assert self.count
My append method-count always refers to next available position
def append(self,item): assert self.count
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
