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 instead of printing out the actual list,e.g. if I append 2 it shd output [2] instead?My referential array

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=len(self.array): raise AssertionError("Array is full") self.array[self.count]=item self.count+=1 return self.array

My append method-count always refers to next available position

def append(self,item): assert self.count=len(self.array): raise AssertionError("Array is full") self.array[self.count]=item self.count+=1 return self.array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!