Skip to Content
Secret Recipes of the Python Ninja
book

Secret Recipes of the Python Ninja

by Cody Jackson
May 2018
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 37m
English
Packt Publishing
Content preview from Secret Recipes of the Python Ninja

How to do it...

Sequence objects (lists and tuples) have the following common operations. Note: s and t are sequences of the same type; n, i, j, and k are integer values, and x is an object that meets the restrictions required by s:

  • x in s: This returns true if an item in sequence s is equal to x; otherwise, it returns false
  • x not in s: This returns true if no item in sequence s is equal to x; otherwise, it returns false
  • s + t: This concatenates sequence s with sequence t (concatenating immutable sequences creates a new object)
  • s * n: This adds s to itself n times (items in the sequence are not copied, but referenced multiple times)
  • s[i]: This retrieves the ith item in sequence s, with count starting from 0 (negative numbers start counting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Expanding World of Python

The Expanding World of Python

Dane Hillard

Publisher Resources

ISBN: 9781788294874Supplemental Content