--- title: 'Python Challenge Day 2 - String repeat' disqus: hackmd --- ## Python Challenge Day 2 - String repeat ### DESCRIPTION Write a function that accepts an integer n and a string s as parameters, and returns a string of s repeated exactly n times. ### Examples (input -> output): ```gherkin= 6, "I" -> "IIIIII" 5, "Hello" -> "HelloHelloHelloHelloHello" ``` 程式邏輯 --- 目的:重複字串 1. 欲重複的次數 x 字串 Solution --- ``` python def repeat_str(repeat, string): return repeat * string ``` * 使用 def 關鍵字來定義函數(repeat_str) ## 參考資源 :::info * [Kata](https://www.codewars.com/kata/5c374b346a5d0f77af500a5a/javascript) :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up