Published Date : 2020年4月21日13:49

【Python】Get index number, get value from index number

This blog has an English translation

YouTubeにアップした動画、「【Python】Part 3 - 一分間の3Dアニメーションで理解するPythonの基礎」の補足説明の記事です。

Here's a little more about the "【Python】Part 3 - Understand the basics of Python with a one-minute 3D animation" video I uploaded to YouTube.


Let's retrieves a value by specifying the index number of Python variable, or retrieves an index number by specifying a value


You can read this post in a minute, just like the video above.

Responsive image


First, Start up a command prompt or terminal and type Python.

$ python

Responsive image


The len () method can retrieve the length of a variable.

Responsive image


Non-list strings are counted one by one because the string is iterable.

Responsive image



An iterable is an object that can be repeated in a for statement.

The ability to repeat in a for statement means that strings appear to stick together, but can actually be retrieved individually.

Responsive image


The index() method returns the index number of a specified number or character from a list.

Responsive image


Index numbers are easier to understand if you look at the diagram below. In short, it is a number that represents the order.

Responsive image

Responsive image

Responsive image


Remember that the programming index numbers start at "0".

Responsive image


Let's use the print() function to print the value of a variable from its index number.


See You Next Page!