Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Set Statements

The for statement works directly with sets, because they are iterable. A set is not a sequence, but it is like a sequence because we can iterate through the elements using a for statement.

Here we create three sets: even, odd and zero to reflect some standard outcomes in Roulette. The union of all three sets is the complete set of possible spins. We can iterate through this resulting set.

>>> even= set( range(2,38,2) )
>>> odd= set( range(1,37,2) )
>>> zero= set( (0,'00') )
>>> for n in even|odd|zero:
        print n

  Published under the terms of the Open Publication License Design by Interspire