L
L
LolkaProfitka2021-11-18 12:47:10
Python
LolkaProfitka, 2021-11-18 12:47:10

How to return the desired value?

For n = 2 it returns:
x
x

Need to return:
x
xx

The function is as follows:

def sq(n):
    for i in range(1, n + 1):
        # print(i * 'x')
        z = i * 'x' + '\n'
        return z*n

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-11-18
@LolkaProfitka

def sq(n):
  return '\n'.join('x' * (i + 1) for i in range(n))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question