We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b0f363 commit a1eb36dCopy full SHA for a1eb36d
Hongjoo/lv2/큰수식찾기.py
@@ -0,0 +1,34 @@
1
+
2
+def func(f):
3
+ # 1, ops (종류) , 위치 찾기
4
+ f = list(f)
5
+ answer =0
6
+ ops = []
7
+ nums =[]
8
+ s = 0
9
+ for i in range(len(f)):
10
+ if f[i] in ["+","*","-"] :
11
+ ops.append([i,f[i]]) # [idx, + ]
12
+ if len(f[s:i]) >= 1 :
13
+ num= "".join(f[s:i])
14
+ nums.append(num)
15
+ s=i+1
16
+ nums.append("".join(f[ops[-1][0]+1:]))
17
+ nums= list(map(int, nums))
18
+ # 연산자 우선순위
19
20
+ answer = nums[0]
21
+ for j in range(len(ops)):
22
+ if ops[j][1] == "*":
23
+ answer *= nums[j+1]
24
+ elif ops[j][1] == "-":
25
+ answer -= nums[j+1]
26
+ elif ops[j][1] == "+":
27
+ answer += nums[j+1]
28
+ return answer
29
30
31
+a,b = input().split()
32
+out=max(func(a),func(b))
33
+# print ("Hello Goorm! Your input is " + user_input)
34
+print(out)
0 commit comments