Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Pythonにおける文字列インデックス | セクション
Pythonにおける変数と演算子

Pythonにおける文字列インデックス

メニューを表示するにはスワイプしてください

文字列内の特定の文字にアクセスするには、角括弧内にインデックス番号を指定します。Pythonはゼロベースのインデックスを使用しているため、インデックス番号は文字の位置と直接一致しません。

12345
# The string of digits word = "codefinity" # Access the character at index 1 (second character) print(word[1])

Pythonの負のインデックス指定は、末尾から要素にアクセスする方法。先頭(インデックス0)からではなく、末尾(インデックス-1)から始まり、-1は最後の要素を表す。

12345
# The string of digits word = "codefinity" # Access the characters at index -1 and -9 (first and last ones) print(word[-1], word[-10])
question mark

次の文字列において、インデックス [4] および [-8] にある文字は何ですか?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  7

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 1.  7
some-alt