Nested Loop Python

后端 未结 13 2265
一个人的身影
一个人的身影 2020-12-09 23:40
count = 1
for i in range(10):
    for j in range(0, i):
        print(count, end=\'\')
        count = count +1
    print()
input()

I am writing a

13条回答
  •  情歌与酒
    2020-12-10 00:19

    I realised that the problem is solved but here's how you wanted your code to look like.

    count=0
    for i in range(10):
        for j in range(0, i):
            print (count, end='')
    count +=1
    print()
    

    i think @Dannnno answer is shorter and straight to the point :)

提交回复
热议问题