Instead of printing the numbers in the sequence it should collect them in a list and return the list. Here is the code that prints numbers in the sequence:
def collatz_sequence(n):
while n > 1:
print(n)
if n % 2 == 1:
n = 3*n + 1
else:
n = n // 2