Skip to content

Commit d62d2d8

Browse files
authored
init: python task
1 parent 48fc968 commit d62d2d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

49. Python Named Arguments.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'''Реализуйте функцию trim_and_repeat(), которая принимает три параметра: строку, offset — число символов, на которое нужно обрезать строку слева и repetitions — количество раз, сколько ее нужно повторить, и возвращает получившуюся строку.
2+
Число символов для среза по умолчанию равно 0, а повторений — 1.
3+
4+
text = 'python'
5+
print(trim_and_repeat(text, offset=3, repetitions=2)) # => honhon
6+
print(trim_and_repeat(text, repetitions=3)) # => pythonpythonpython
7+
print(trim_and_repeat(text)) # => python'''
8+
9+
def trim_and_repeat(text, offset=0, repetitions=1):
10+
return f'{text[offset:] * repetitions}'

0 commit comments

Comments
 (0)