Pythonのリストは、なんと足し算することで結合することが可能です。
リストの結合
![python リスト 連結1](https://sunagitsune.com/wp-content/uploads/2022/09/0193074f003bc182f7c4a074919d7cf6.png)
複数のリストを用意しておきます。
#python
リスト1 = ["a","b","c"]
リスト2 = ["d","e","f"]
リスト3 = リスト1 + リスト2
print(リスト3)
このふたつのリストをひとつにまとめるには、ふたつのリストを足し算でつないでやればOKです。
![python リスト 連結2](https://sunagitsune.com/wp-content/uploads/2022/09/a3328a7329a8e9b21d15b3842625a1ee.png)
実行結果です。
![python リスト 連結3](https://sunagitsune.com/wp-content/uploads/2022/09/7059ea671319ad019433fe350b735604.png)
足し算の左にあるリストほど、結合したリストの頭のほうにきます。
![](https://sunagitsune.com/wp-content/uploads/2022/05/laptop-g2651bd324_1280-160x90.png)
Python操作方法、関数・メソッドリファレンス
使用用途別にまとめたPythonリファレンスページです。
初期準備、基本概念
ダウンロード、インストール、起動
ShellとEditor、保存、実行
保存したPythonの起動
コメント、docstring、行またぎ
コメント、...
コメント