[ Code Kata ] ๐Ÿคฏ Python #23 ์žฌ๊ท€ (Recursion)

Haileeยท2021๋…„ 1์›” 2์ผ
0

[ Code Kata ]

๋ชฉ๋ก ๋ณด๊ธฐ
28/28
post-thumbnail

๋ฌธ์ œ

์žฌ๊ท€(Recursion)

๐Ÿ‘‰๐Ÿป ์žฌ๊ท€ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ž€?

str ์ด๋ผ๋Š” 'string'์„ ๋„˜๊ฒจ์ฃผ๋ฉด ๊ธ€์ž์ˆœ์„œ๋ฅผ ๋ฐ”๊ฟ”์„œ returnํ•ด์ฃผ์„ธ์š”.

  • reverse ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ์€ ๋‹น์—ฐํžˆ ๊ธˆ์ง€์ž…๋‹ˆ๋‹ค!
input: 'hello'
output: 'olleh'
  • ํžŒํŠธ
    ์•„๋ž˜์˜ ์ฝ”๋“œ๊ฐ€ ์–ด์ƒ‰ํ•œ ๊ฒƒ์€ ์•„๋‹ˆ๊ฒ ์ฃ ?
    (ํ•จ์ˆ˜์˜ return์— string์„ ๋ถ™์—ฌ์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ)
def getName(name):
  return name;
-
print(getName('๊น€')+'๋‹˜');
profile
์›น ๊ฐœ๋ฐœ ๐Ÿท๐Ÿ˜Ž๐Ÿ‘Š๐Ÿป๐Ÿ”ฅ

0๊ฐœ์˜ ๋Œ“๊ธ€