Home arrow Python arrow Page 5 - Python Sets

Don't Make Me Repeat Myself! - Python

In our last article we left off discussing Python's version of arrays (the list and dictionary). I also gave you a brief introduction to some Operators. In this tutorial I will tell you about Python's remaining data holder, Sets, and prepare you for a later discussion of Operators in Python.

TABLE OF CONTENTS:
  1. Python Sets
  2. Adding to a Set
  3. Copying Sets and Testing for Membership
  4. Removing Data from A Set
  5. Don't Make Me Repeat Myself!
  6. Using Operators on Sets
By: James Payne
Rating: starstarstarstarstar / 11
December 03, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

You can also perform loops on Sets. Just keep in mind that Sets have no specific order.


usr/local/bin/python


bigword = Set ("acetylsalicyclic")


for n in bigword:

print n,

This will print out every letter in the word acetylsalicyclic. Again since there is no order in Sets, it will print the letters out randomly:

  a t y e c l a s i l c c t y i c



 
 
>>> More Python Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: