The question is to receive the number of multiplication tables and output all the corresponding numbers. However, the number of steps that can be input is limited from 1st to 9th steps, and if other steps are input, It's about printing an error message and ending the program, but I'm asking you a question because I got a compilation error. (Please take into account that you are a beginner.)
a = input
print ("***** %d short *****")
if a < 10:
for i in range(1, 10):
print('{a} x {i} = = {a*i}')
else:
print("Invalid input range".")
The multiplication table was output only when 1 to 9 was entered using the if statement, and the multiplication table was allowed through the for statement. I'd appreciate it if you could answer.
python
a = input is an incorrect usage.
a = int("Enter a step :")
Correct it in the same way.
Since then, other codes have problems with string formatting
print(f'{a} x {i} = = {a*i}')
Or
print ("{0} x {1} = {2}". format(a, i, a*i))
Use it in a way.
Similarly, the front part is also
print(f"****{a} but *****)
Or
print("***** {0} only ******".format(a))
Modify with expression
© 2024 OneMinuteCode. All rights reserved.