Resolved: What's wrong with my code Q3
number = input('Please enter a number between 1 and 12: ')
while (not number.isdigit()) or int(number) < 1 or int(number) > 12:
print('It must be an integer between 1 and 12')
number = int(input('Please enter a number between 1 and 12: '))
print('--------------------------')
print()
print(f'This is the {number} times table')
print('--------------------------')
for i in range(1,13):
print(f'{number} X {i} = {i*number}')
if i entered 3 it gives me
3 X 1 = 3
3 X 2 = 33
3 X 3 = 333
3 X 4 = 3333
3 X 5 = 33333
3 X 6 = 333333
3 X 7 = 3333333
3 X 8 = 33333333
3 X 9 = 333333333
3 X 10 = 3333333333
3 X 11 = 33333333333
3 X 12 = 333333333333
In the last line, your print statement is telling it to print out the same number 'i' times.
Change the last line to
print(f'{number} X {i} = {i*int(number)}')
And it should work.
I get it but in the video, there wasn't that "int()" I've searched for the difference between adding it and not and I couldn't find any difference
Ahmed, if you do not add int(), your code automatically takes input as string. Therefore, you code output is multiplying string