「Python」append()でリストへの要素を追加するサンプル

2021年2月28日

書式
リスト名.append(要素)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cftLst = ["A001", "B002", "C003"]
print(cftLst)
cftLst.append("D004")
print(cftLst)
cftLst = ["A001", "B002", "C003"] print(cftLst) cftLst.append("D004") print(cftLst)
cftLst = ["A001", "B002", "C003"]

print(cftLst)
cftLst.append("D004")

print(cftLst)

結果
['A001’, 'B002’, 'C003’]
['A001’, 'B002’, 'C003’, 'D004’]

Python

Posted by arkgame