2024-04-27 03:10:43 发布
网友
def triangular(n): tri = 0 for i in range(1, n+1): tri = tri + i print ("The answer is equal to" +(tri)) triangular(4)
我只是需要帮助打印报表,因为它不起作用。我想把答案打印出来
print("The answer is equal to", tri)
或者
print("The answer is equal to %i"%tri)
print("The answer is equal to {}".format(tri))
docs还有更多的方法可以做到这一点。你知道吗
你需要把你的int转换成str。你知道吗
int
str
# str is optional here because print will call str on its arguments for you print("The answer is equal to", str(i))
# str is not optional here because you are concatenating print("The answer is equal to " + str(i))
或者
或者
docs还有更多的方法可以做到这一点。你知道吗
你需要把你的
int
转换成str
。你知道吗或者
相关问题 更多 >
编程相关推荐