I am attempting to create a program asking the user for two inputs, from this a multiplication table will be created. For example, the user inputs 2 and 5.
Enter a starting integer of less than 1,000 and greater than 0: 2
Enter an ending integer greater than the first number and less than 1,000 : 5
I get something that looks like this:
4 6 8 10
6 9 12 15
8 12 16 20
10 15 20 25
However the math is wrong and I want 2-5 printed at the top and on the left side.
This is what I have so far:
# In this program I will help you make a multiplication table
print('In this program, I will help you make a multiplication table.')
print('\n')
# Ask user for a starting integer
start_value = int(input('Enter a starting integer of less than 1,000 and greater than 0: '))
while start_value < 1 and start_value > 1000:
start_value = int(input('Enter a starting integer of less than 1,000 and greater than 0: '))
# Ask user for an ending integer
end_value = int(input('Enter an ending integer greater than the first number and less than 1,000 : '))
while end_value < 0 and end_value > 1000 and end_value > start_value:
print('Invalid number')
end_value = int(input('Enter an ending integer greater than the first number and less than 1,000 : '))
for num1 in range(start_value, end_value+1):
for num2 in range(start_value, end_value+1):
table = (num1*num2)
print(format(table, '6d'), end = '')
print('\n')
I feel like something is up with the for-loop, I hope this makes sense, I greatly appreciate all the help!
Thank you!!!