I started creating an array, then i referenced its element with lists. Now I want to print the entire array (this is: all the lists on the array), i created a function "show" and "show array" but always print the last element of the array
IN:
class Test: pass def read(v, r): n = len(v) for i in range(0, n): v[i] = r v[i].number= 5+i v[i].name = i*2 v[i].author = i+6 v[i].genre = i*3 v[i].quantity = i+2 def show_array(v): n = len(v) for i in range(0, n): show(v[i]) def show(reg): print(reg.number, end=' ; ') print(reg.name, end=' ; ') print(reg.author, end=' ; ') print(reg.genre, end=' ; ') print(reg.quantity) def menu(): v = 2 * [None] t= Test() read(v, t) show_array(v) menu() OUT:
6 ; 2 ; 7 ; 3 ; 3 6 ; 2 ; 7 ; 3 ; 3
vis a list, so calling it an array is a bit confusing.r=Testand sayv[i] = r()to create a new instance ofTest