---
# System prepended metadata

title: HW_スライス
tags: [homework]

---

###### tags: `homework`
# HW_スライス
## 1
```python=
string = input("Please enter string: ")
judge = input("Please enter the suffix you want to judge: ")
restring = string[len(string):-len(judge)-1:-1] #終点は入力した数の一つ手前までなので+1を忘れないように
#語を後ろから読んで等しいかどうか確認
rejudge = judge[len(judge)::-1]

if rejudge == restring:
    print("True")
else:
    print("False")
```

## 2
```python=
import random
n = int(input("Input n: "))
Original = list()
for i in range(n):
    Original.append(random.randint(1, 101))
print("Original: {}".format(Original))
Original.sort() #昇順にソート
Result = Original[1:n-1] #ソートしたため一番最初と最後の数がそれぞれ最大最小
print(Result)
```

## 3
```python=
birthday = ["19930911", "20010621", "19801110", "19980507", "20100101", "20090519", "20140712", "20110323", "19990415", "20001224"]
year = []
year = [birthday[i][0:4] for i in range(len(birthday))]
#birthdayのリストの長さだけ4桁スライスを繰り返し
print(year)

month = []
month = [birthday[i][4:6] for i in range(len(birthday))]
print(month)

newyear = []
newyear = [i for i in year if int(i) >= 2000]
print(newyear)

newmonth = []
newmonth = ["7~12" if int(i)>=7 and int(i)<=12 else "1~6" for i in month]
print(newmonth)
```

