[๐ปPython] pearl's python ๋ณ์๋ฆฌ ํ์ถ๊ธฐ ๐ฃ
[Python] ๋ง์ง๋ง ๋ ์์
seapearl
2025. 4. 1. 15:04
๋ฌธ์ ์ค๋ช
์ ์ ๋ฆฌ์คํธ num_list๊ฐ ์ฃผ์ด์ง ๋, ๋ง์ง๋ง ์์๊ฐ ๊ทธ์ ์์๋ณด๋ค ํฌ๋ฉด ๋ง์ง๋ง ์์์์ ๊ทธ์ ์์๋ฅผ ๋บ ๊ฐ์ ๋ง์ง๋ง ์์๊ฐ ๊ทธ์ ์์๋ณด๋ค ํฌ์ง ์๋ค๋ฉด ๋ง์ง๋ง ์์๋ฅผ ๋ ๋ฐฐํ ๊ฐ์ ์ถ๊ฐํ์ฌ returnํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
์ฝ๋
def solution(num_list):
if num_list[-2] < num_list[-1]:
num_list.append(num_list[-1] - num_list[-2])
return num_list
else:
num_list.append(num_list[-1]*2)
return num_list