Python while loop help

Hey guys, I am wondering why every time I try to use a while loop (well any loop for that matter) my code doesn’t seem to loop. I know Python is big on indentation so maybe that is my issue, but I am not sure. I will include a small while loop I tried using to get multiples of a number and all it does it print one time. Thanks in advance for any help.

def first_three_multiples(num):
mult = 0
while mult < 3:
print(num * mult)
mult += 1
return num * 3

Uncomment these function calls to test your first_three_multiples function:

first_three_multiples(10)

should print 10, 20, 30, and return 30

first_three_multiples(0)

should print 0, 0, 0, and return 0

the forum keeps auto spacing my indents back to the edge, sorry

Check that the return is outside the loop
so that it does not stop the loop form continuing.

def first_three_multiples(num):
  mult = 0
  while mult < 3:
    print(num * mult)
    mult += 1
  return num * 3  # indented less than the stuff in the loop
2 Likes

Thanks! I will give this a shot.

Thanks again, this worked for me. I really need to pay attention to my indents.