'programmers' ์นดํ
๊ณ ๋ฆฌ์ ๊ธ ๋ชฉ๋ก (71 Page)
[python] ๋ง์ง๋ง ๋ ์์
๋ฌธ์ ์ค๋ช
์ ์ ๋ฆฌ์คํธ num_list๊ฐ ์ฃผ์ด์ง ๋, ๋ง์ง๋ง ์์๊ฐ ๊ทธ์ ์์๋ณด๋ค ํฌ๋ฉด ๋ง์ง๋ง ์์์์ ๊ทธ์ ์์๋ฅผ ๋บ ๊ฐ์ ๋ง์ง๋ง ์์๊ฐ ๊ทธ์ ์์๋ณด๋ค ํฌ์ง ์๋ค๋ฉด ๋ง์ง๋ง ์์๋ฅผ ๋ ๋ฐฐํ ๊ฐ์ ์ถ๊ฐํ์ฌ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์. ์
์ถ๋ ฅ ์num_listresult[2, 1, 6][2, 1, 6, 5][5, 2, 1, 7, 5][5, 2, 1, 7, 5, 10] ์ ์ถ ๋ด์ญdef solution(num_list): num_list.append(num_list[-1] - num_list[-2]) if num_list[-1] > num_list[-2] else num_list.append(num_list[-1]*2) return num_list ํ๋ก๊ทธ๋๋จธ์ค ์ฝ๋ฉ ๊ธฐ์ด ..
2024. 7. 19.