On 11/1/2012 11:34 AM, Ashley Fowler wrote:
Hello I am trying to add a str method to a Set ADT implementation to
allow a user to print the contents of a set. However the resulting
string should look like that of a list. except I am suppose to use
curly brackets to surround the elements.
For an example...
>>> set1 = Set()
>>> print(set1)
{}
Question is how do you implement the "curly brackets" in my str method?
This is what I have so far...
def __init__( self, *initElements ):
self._theElements = list()
def __str__(self):
return self._theElements
Please include the class statement.
Give us an example of the desired output when theElementsis not empty.
Why not create theElements as a set to start with?
what is Set ADT? is it important that we know that?
-- Bob Gailer
919-636-4239
Chapel Hill NC
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor