LoginSignup
1
0

More than 1 year has passed since last update.

PYTHONについて

Posted at

変数の使い方

price = 100
price
100
price + 10
110

文字列を扱う

name = 'ヘスティ'
name
'ヘスティ'

append
リストの末尾に追加する。
my_list.append(10)

clear
リストを空にする。
my_list.clear()

copy
リストのコピーを返す。
[1,2,3].copy()
=>[1,2,3]

count
リスト内に何個あるかを返す。
[1,1,2,1,2,3].count(1)
=>3

extend
リストに別のリストを追加する。
my_list.extend([4,5,6])

index
リスト内の位置を返す。
['burger','steak','chiken'].index('steak')
=>1

insert
リストの指定した位置に追加する。
my_list.insert(0,'追加データ')

pop
リスト内の要素を削除する。
「引数なし」はー1と同義
my_list.pop()
=>10

remove
リスト内の要素を削除する。
popと違い、値で指定する。
my_list.remove('削除したい値')

sort
リストを並べ替える。
reverse=Trueにすると、結果を逆にする
my_list.sort(reverse=True)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0