File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed
Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ # 31. 문자열을 정수로 바꾸기
2+
3+ def solution (s ):
4+ answer = ''
5+
6+ answer += s
7+ answer = int (answer )
8+ return answer
9+
10+ str_1 = '1234'
11+ str_2 = '-1234'
12+
13+ print (solution (str_1 ))
14+ print (solution (str_2 ))
Original file line number Diff line number Diff line change 1+ # 17. 서울에서 김서방 찾기
2+
3+ def solution (seoul ):
4+ answer = ''
5+
6+ for i in range (len (seoul )):
7+ if seoul [i ] == 'Kim' :
8+ answer += '김서방은 ' + str (i ) + '에 있다'
9+
10+ return answer
11+
12+ seoul_1 = ['Jane' , 'Kim' ]
13+ print (solution (seoul_1 ))
14+
15+ def solution_best (seoul ):
16+ answer = '김서방은 {}에 있다' .format (seoul .index ('Kim' ))
17+
18+ return answer
19+
20+ print (solution_best (seoul_1 ))
Original file line number Diff line number Diff line change 1+ # 18. 수박수박수박수박수박수?
2+
3+ def solution (n ):
4+ answer = ''
5+
6+ if n == 1 :
7+ answer = '수'
8+ elif n == 2 :
9+ answer = '수박'
10+ else :
11+ answer += '수박'
12+ if n % 2 == 0 :
13+ answer += (n // 2 - 1 ) * '수박'
14+ else :
15+ answer += (n // 2 - 1 ) * '수박' + '수'
16+
17+ return answer
18+
19+ n_1 = 3
20+ n_2 = 4
21+
22+ print (solution (n_1 ))
23+ print (solution (n_2 ))
24+
25+ def solution_best (n ):
26+ answer = '수박' * n
27+
28+ return answer [:n ]
29+
30+ print (solution_best (n_1 ))
31+ print (solution_best (n_2 ))
You can’t perform that action at this time.
0 commit comments