Class 1 HW D

Why does the problem say that my code is incorrect?
Question Description: Our goal in this question is to print out a number triangle.
Start with the integer 1. The ith line contains i integers, and every number in the triangle takes up 4 positions (aligned to the right).
(In C, you can use “%4d” to format the output, which takes up 4 positions and aligns to the right).

Code:
n = int(input())
c = 1
for i in range(1, n + 1):
for j in range(1,i+1):
print(“%4d”%c, end=" ")
c += 1
print()

1 个赞

......I don't understand

It AC code?

You can format it

老帖,勿回。
@Dalton 关帖。

1 个赞

以后把我也 @ 吧