r = [1,2,3,4,5,1,2,3]
print(r.index(3)) #3を検索して最初のインデックスを返す
print(r.index(3, 3)) #start=3 で検索
print(r.count(3))
r.sort()
print(r)
r.sort(reverse=True) #降順で並び替え
print(r)
r.reverse()
print(r)
s = 'My name is Mike.'
to_split = s.split(' ')
print(to_split)
x = ' '.join(to_split) #スペースで結合
print(x)
実行結果:
2
7
2
[1, 1, 2, 2, 3, 3, 4, 5]
[5, 4, 3, 3, 2, 2, 1, 1]
[1, 1, 2, 2, 3, 3, 4, 5]
['My', 'name', 'is', 'Mike.']
My name is Mike.