¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
Help me solve the problem to output the correct answer, what should be the value of multiplier
def multiplication_table(number): # Initialize the appropriate variable multipliyer = # Complete the while loop condition. while number > 0: result = number * multiplier if result > 25 : # Enter the action to take if the result is greater than 25 break print(str(number) + "x" + str(multiplier) + "=" + str(result)) # Increment the appropriate variable number += 1 multiplication_table(3) # Should print: # 3x1=3 # 3x2=6 # 3x3=9 # 3x4=12 # 3x5=15 multiplication_table(5) # Should print: # 5x1=5 # 5x2=10 # 5x3=15 # 5x4=20 # 5x5=25 multiplication_table(8) # Should print: # 8x1=8 # 8x2=16 # 8x3=24
2 Respuestas
+ 3
I found a few errors.
First of all, why multiplayer is not assigned a value?
Second, from how you call your function, variable “number” should not be changed when you print, why it is increase by 1 after every loop?
Third, if you call your function with a positive number, the condition will always be True and create an infinite loop.
+ 1
Assign multipliyer = 1
And in last line write multipliyer +=1
And remove line number +=1