Here's my modification of your code:
for number in range(1, 11):
line_contents = []
for j in range(10):
n = number + j * 10
if (n % 3 == 0):
line_contents.append("Biff")
else:
line_contents.append("{0:4d}".format(n))
print(" ".join(line_contents))
This gives me:
1 11 Biff 31 41 Biff 61 71 Biff 91
2 Biff 22 32 Biff 52 62 Biff 82 92
Biff 13 23 Biff 43 53 Biff 73 83 Biff
4 14 Biff 34 44 Biff 64 74 Biff 94
5 Biff 25 35 Biff 55 65 Biff 85 95
Biff 16 26 Biff 46 56 Biff 76 86 Biff
7 17 Biff 37 47 Biff 67 77 Biff 97
8 Biff 28 38 Biff 58 68 Biff 88 98
Biff 19 29 Biff 49 59 Biff 79 89 Biff
10 20 Biff 40 50 Biff 70 80 Biff 100
The key change is to have a variable n
that contains each number in turn and to test whether this is divisible by 3. You were simply testing whether number
was divisible by 3, i.e. only the number at the beginning of the line.
I've also tried to tidy up how you generate each line by storing a list of strings and building these up in an inner loop. After each inner loop I concatenate the strings and print the result.
Feel free to ask about any parts that aren't clear.