python algorithm
python ํจ์ ๋ชจ์
jsleee
2024. 5. 18. 23:42
๐์ ์ถ๋ ฅ
input()
์๋์ผ๋ก ์ค๋ฐ๊ฟ ๋ฌธ์๋ฅผ ์ ๊ฑฐ, ํ๋กฌํํธ ๋ฌธ์์ด์ ์ถ๋ ฅ ๊ฐ๋ฅ, ์๋ ๋๋ฆผ.
sys.stdin.readline()
์ค๋ฐ๊ฟ ๋ฌธ์๋ฅผ ์ ๊ฑฐํ์ง ์๊ณ ๊ทธ๋๋ก ๋ฐํ(split() ์ด์ฉ), ์๋ ๋น ๋ฆ.
print()
ex) print("hello world", end='\n'), ์ถ๋ ฅํ ์ ์ค๋ก ๋๊น
๐ ๋ฌธ์์ด
.split()
๋ฌธ์์ด์ ์ง์ ํ ๊ตฌ๋ถ์(default: ๊ณต๋ฐฑ)๋ฅผ ๊ธฐ์ค์ผ๋ก ์ฌ๋ฌ๊ฐ์ ๋ฌธ์์ด๋ก ๋๋.
๋๋ณด๊ธฐ
๊ธฐ๋ณธ๋ถํ :
text = "hello world"
parts = text.split()
print(parts) # ['hello', 'world']
๊ตฌ๋ถ์ ์ง์ :
text = "apple,banana,cherry"
parts = text.split(',')
print(parts) # ['apple', 'banana', 'cherry']
.join()
reverse()