Programmers can get confused when building a two-dimensional arrays
Lets create an apartment building with 27 floors and 18 apartment units on each floor from a to r. Starting with 1a to 27r. The solution is to create an inner array of two elements that become a single element of the outer array. Each element in apartment represents a unit consisting of a of a floor and a apt letter. I have demonstrated using Python how you first create the inner array with new then append to the outer array apt
apt= [] for i in range(1,28): for j in range(97, 115): new = [i , chr(j)] apt.append(new) print apt
No comments:
Post a Comment