ํ์ด์ฌ์ผ๋ก ๊ธฐ์ด์ ์ธ ํ๋ก๊ทธ๋จ์ ํ๋ก๊ทธ๋๋ฐ ํ๋ค ๋ณด๋ฉด, ์ค๋ฅ๋ฅผ ํธ๋ค๋ง ํด์ผ ํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค. When user enters invalid input, it is common to abort the program. ๊ทธ๋ ๊ฒ ํ๊ธฐ ์ํด์๋, sys standard library module์ ์ ์๋ exit ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค. from sys import exitif not (userResponse == "n" or userResponse == "y"): exit("Error: you must enter either n or y.") exit(errorMessage) ํ์์ผ๋ก ํ๋ก๊ทธ๋จ terminate ์์ ์ถ๋ ฅ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ธ์๋ก ๋ฃ์ผ๋ฉด ๋ฉ๋๋ค.
There are some ways in Python to analyze string. substring in sReturns True if the string s contains substring and False otherwise.if "-" is not in name: ...s.count(substring)Returns the number of non-overlapping occurrences of substring in s.s.endswith(substring)Returns True if the string s ends with the substring and False otherwise.s.startswith(substring)Returns True if the string s starts w..
https://www.acmicpc.net/problem/2563 2563๋ฒ: ์์ข
์ด ๊ฐ๋ก, ์ธ๋ก์ ํฌ๊ธฐ๊ฐ ๊ฐ๊ฐ 100์ธ ์ ์ฌ๊ฐํ ๋ชจ์์ ํฐ์ ๋ํ์ง๊ฐ ์๋ค. ์ด ๋ํ์ง ์์ ๊ฐ๋ก, ์ธ๋ก์ ํฌ๊ธฐ๊ฐ ๊ฐ๊ฐ 10์ธ ์ ์ฌ๊ฐํ ๋ชจ์์ ๊ฒ์์ ์์ข
์ด๋ฅผ ์์ข
์ด์ ๋ณ๊ณผ ๋ํ์ง์ ๋ณ์ด ํํํ๋๋ก www.acmicpc.net ์ฝ๋ paper_list = [[0 for i in range(100)] for j in range(100)] times = int(input()) for _ in range(times): x, y = map(int, input().split()) for row in range(x, x+10): for col in range(y, y+10): paper_list[row][col] = 1 result ..
https://www.acmicpc.net/problem/10789 10789๋ฒ: ๊ฐ์ ํค๋ณด๋ ์
๋ ฅ ์
๋ ฅ์ ์ฒซ ๋ฒ์งธ ์ค(ํ)์๋ ๋ ๊ฐ์ ์ ์ r๊ณผ c (1 ≤ r, c ≤ 50)๊ฐ ํฌํจ๋์ด ๊ฐ์ ํค๋ณด๋ ๊ฒฉ์์ ํ๊ณผ ์ด ์๋ฅผ ์ ๊ณตํฉ๋๋ค. ๊ฐ์ ํค๋ณด๋๋ ๋ค์ r ํ์ ํ์๋๋ฉฐ ๊ฐ ํ์๋ c ๋ฌธ์๊ฐ ๋ค์ด ์์ต๋๋ค. www.acmicpc.net ์ฝ๋ my_list = [] for _ in range(5): my_list.append(list(input())) for row in range(15): for col in range(5): try: print(my_list[col][row], end="") except: continue ์ค๋ช
1. my_list์ ์
๋ ฅ๊ฐ์ ํ์ค ์ฉ list๋ก ๋ณํํ์ฌ ์ ์ฅํ๋ค. (2..