Python Tuple - Element access using subscript notation

A tuple element is accessed by using its indices. The index is specfied using subscript notation tuple[element_index].

Example:

>>> booktypes=("Fiction","Non-Fiction","Science-Fiction","Philosophy","Biographies","Auto-Biographies","History")

>>> index = 0;

>>> count_booktypes=len(booktypes)

>>> while index < count_booktypes:

...     print(booktypes[index])

...     index = index+1

...

Fiction

Non-Fiction

Science-Fiction

Philosophy

Biographies

Auto-Biographies

History


Copyright 2024 © pythontic.com