回答編集履歴
1
追記
test
CHANGED
@@ -21,3 +21,37 @@
|
|
21
21
|
print(min(le_lst)) # 149.4
|
22
22
|
|
23
23
|
```
|
24
|
+
|
25
|
+
あるいはもっと単純に以下のように2つの変数を用意しておけばソートの必要もないかと思います。
|
26
|
+
|
27
|
+
```Python
|
28
|
+
|
29
|
+
import sys
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
lst = [['ge', '121.7'], ['ge', '125.0'], ['le', '162.4'], ['le', '153.5'], ['ge', '119.6'], ['le', '182.4'], ['le', '149.4'], ['le', '192.7'], ['le', '168.8'], ['ge', '110.0'], ['le', '180.9'], ['ge', '119.9'], ['le', '152.7'], ['le', '180.8'], ['le', '152.4']]
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
ge = sys.float_info.min
|
38
|
+
|
39
|
+
le = sys.float_info.max
|
40
|
+
|
41
|
+
for v in lst:
|
42
|
+
|
43
|
+
if v[0] == 'ge':
|
44
|
+
|
45
|
+
ge = max(float(v[1]), ge)
|
46
|
+
|
47
|
+
else:
|
48
|
+
|
49
|
+
le = min(float(v[1]), le)
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
print(ge) # 125.0
|
54
|
+
|
55
|
+
print(le) # 149.4
|
56
|
+
|
57
|
+
```
|