所屬專題:[Python社區](README.md)
 
## 問題
**輸入:** 一個至多200個字符長度的字符串`$ s $`,和4個整數`$ a $`, `$ b $`, `$ c $`, `$ d $`.
**輸出:** 該字符串的兩個子串,一個子串從下標`$ a $`到`$ b $`,另一個子串從下標`$ c $`到`$ d $`(兩個子串下標范圍均包含右端在內)。
**樣例數據:**
```
HumptyDumptysatonawallHumptyDumptyhadagreatfallAlltheKingshorsesandalltheKingsmenCouldntputHumptyDumptyinhisplaceagain.
22 27 97 102
```
**樣例輸出:**
```
Humpty Dumpty
```
 
## 背景知識
該問題涉及Python語言的基本序列類型——字符串、列表的使用。詳情請查閱ROSALIND網站上[關于該問題的背景說明](http://rosalind.info/problems/ini3/)。
 
## 解答
```python
def slices(s, a, b):
"""在字符串s中取下標范圍[a, b]的切片(包含b)"""
sl = s[a:b+1]
return sl
## --main--
l = []
with open("rosalind_ini3.txt", 'r') as f1:
for line in f1.readlines():
line = line.strip('\n')
l.append(line)
s = l[0]
pos = list(map(int, l[1].split()))
result = str(slices(s, pos[0], pos[1])) + ' ' + str(slices(s, pos[2], pos[3]))
with open("rosalind_ini3_out.txt", 'w') as f2:
f2.write(result)
```