Travel Agency

Indexing, Slicing, and Matrixes

Because lists are sequences, indexing and slicing work the same way for lists as they do for strings.

Assuming following input −

L =["spam","Spam","SPAM!"]

Source

http://www.tutorialspoint.com

 

Python ExpressionResults Description
L[2] "SPAM!" Offsets start at zero
L[-2] "Spam" Negative: count from the right
L[1:] ["Spam", "SPAM!"] Slicing fetches sections

کلمات کلیدی:


نوشته شده توسط Abteen 94/10/7:: 5:24 عصر     |     () نظر