반응형
Your goal is to return multiplication table for number
that is always an integer from 1 to 10.
For example, a multiplication table (string) for number == 5
looks like below:
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
P. S. You can use \n in string to jump to the next line.
Note: newlines should be added between rows, but there should be no trailing newline at the end. If you're unsure about the format, look at the sample tests.
Solution:
def multi_table(number):
return "\n".join(f"{i} * {number} = {i*number}" for i in range(1, 11))
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1018. Find the smallest integer in the array (0) | 2022.10.18 |
---|---|
1017. Enumerable Magic - Does My List Include This? (0) | 2022.10.17 |
1015. simple calculator (0) | 2022.10.15 |
1014. Find Multiples of a Number (0) | 2022.10.14 |
1013. Area or Perimeter (0) | 2022.10.13 |