I’m attempting to make a 2-10 multiplication table in Python. If you enter an invalid number, the system will notify you and prompt you to enter another number. It is also expected to append a # to all even integers. I’m having difficulties continuing after an invalid entry, and I’m also having trouble placing a # on all even integers. My current code is shown below.
def main():
rows = int(input("What size multiplication table would you like (2-10): "))
if rows <=1 or rows >10:
print (" Invalid Entry - Enter a number between 2 - 10 ")
else:
counter = 0
multiplicationTable(rows,counter)
def multiplicationTable(rows,counter):
size = rows + 1
for i in range (1,size):
for nums in range (1,size):
value = i*nums
print(value,sep=' ',end="\t")
counter += 1
if counter%rows == 0:
print()
else:
counter
main()
While true: will run indefinitely naturally, according to this video. However, the secret is in the continue and break statements. Continue will cause it to restart at the top of the loop, whereas break will cause it to quit the loop after the procedure is completed. Is that good?