[Python] ๋ง์ง๋ง ๋ ์์
2025. 4. 1. 15:04ใ[๐ปPython] pearl's python ๋ณ์๋ฆฌ ํ์ถ๊ธฐ ๐ฃ
๋ฌธ์ ์ค๋ช
์ ์ ๋ฆฌ์คํธ 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
'[๐ปPython] pearl's python ๋ณ์๋ฆฌ ํ์ถ๊ธฐ ๐ฃ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๊ฐ๊น์ด 1 ์ฐพ๊ธฐ (0) | 2025.04.04 |
---|---|
[Python] ์ ์กฐ์ํ๊ธฐ 1 (0) | 2025.04.03 |
[Python]x ์ฌ์ด์ ๊ฐ์ (0) | 2025.03.30 |
[Python] 0 ๋ผ๊ธฐ (0) | 2025.03.29 |
[python]๊ผฌ๋ฆฌ ๋ฌธ์์ด (0) | 2025.03.26 |