[Python] ๋ฆฌ์คํธ ์๋ฃํ
โถ ๋ฆฌ์คํธ๋ ์ด๋ป๊ฒ ๋ง๋ค๊ณ ์ฌ์ฉํ ๊น? >>> odd = [1, 3, 5, 7, 9] ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค ๋๋ ์์์ ๋ณด๋ ๊ฒ๊ณผ ๊ฐ์ด ๋๊ดํธ([])๋ก ๊ฐ์ธ ์ฃผ๊ณ ๊ฐ ์์๊ฐ์ ์ผํ(,)๋ก ๊ตฌ๋ถํด ์ค๋ค. -์ฌ๋ฌ ๊ฐ์ง ๋ฆฌ์คํธ์ ์๊น์ >>> a = [] >>> b = [1, 2, 3] >>> c = ['Life', 'is', 'too', 'short'] >>> d = [1, 2, 'Life', 'is'] >>> e = [1, 2, ['Life', 'is']] ์ฆ, ๋ฆฌ์คํธ ์์๋ ์ด๋ ํ ์๋ฃํ๋ ํฌํจ์ํฌ ์ ์๋ค. โถ ๋ฆฌ์คํธ์ ์ธ๋ฑ์ฑ๊ณผ ์ฌ๋ผ์ด์ฑ -๋ฆฌ์คํธ์ ์ธ๋ฑ์ฑ ์์ 1) >>> a = [1, 2, 3] >>> a [1, 2, 3] >>> a[0] 1 >>> a[0] + a[2] ← 1 + 3 4 >>> a[-1] ←..
2021. 2. 5.