나는 이렇게 학습한다/Algorithm & SQL

0113. Build a square

daco2020 2023. 1. 13. 15:13
반응형

I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 and 50.

Example

n = 3, so I expect a 3x3 square back just like below as a string:

+++
+++
+++



Solution:

def generate_shape(n: int) -> str:
    return "\n".join("+" * n for i in range(n))


반응형