The program calculates the multiplication table from 0 to 12 for the number the user has entered. I am trying to display the contents of the array with the results in it by for looping through it. However, it only displays the tables from 0 to 11, but not the 12th one, even if the 12th data is there.
Here is what I came up with:
def multiplicationTable():
nb = int(input("Please enter a number between 1 and 12 : \n"))
table = array('i')
for i in range(0,12):
table.append(i * nb)
for i in range(len(table)):
print(str(nb) + "x" + str(i) + " = " + str(table[i]))
The output looks like this:
4x0 = 0
4x1 = 4
4x2 = 8
4x3 = 12
4x4 = 16
4x5 = 20
4x6 = 24
4x7 = 28
4x8 = 32
4x9 = 36
4x10 = 40
4x11 = 44
What could be causing that ? Coming from VB and C# so I may be mistaking the i as an index, while it is a value from the array, but I really don't see how I could be fixing this. Thank you !