
Eli J. answered 01/29/20
Expert Math Tutor: All Ages and Courses
You may want to use the "</>" button to help format your question as code. That way we can see your indentation, etc.
First, either you can pass the parameters a and b as arguments to mult_table, or you can ask for them as inputs inside the function. But choose one or the other.
There's a bit of a problem with converting your input immediately to int. Either the string entered is something like '42' in which case there is no problem, or the string is '42.2' or worse, something like 'ss2%' and int() will raise an exception (error), since it's an invalid string to convert. Further, is_integer() is actually a method for decimals, not integers, so even if the conversion went right, you're then going to get an exception raised later.
Maybe is_integer() might be handy if we were instead getting a and b passed as arguments. Especially since the better way to handle type casting input strings might be with a try/except block inside a while loop. Since I don't know how much of this you've learned yet, let's instead do it the argument-passing way.
Your for loop uses i as its iteration variable, but doesn't use i anywhere in the loop as I think you want it to. The logic of this loop needs to be fixed.
There are a couple other small issues. For example your if statement is missing a colon, and you don't actually need the == True part since a.is_integer() already evaluates to True or False. You also need parentheses on is_integer().
Putting all that together, here's an example that I think does what you're looking for.
Of course, all the business with changing to and from floats is just to artificially use the "is_integer()" method like you said you needed to. If you don't need to use that, but still wanted to test, you could do it more simply: