[Tutor] back-quotes to print dictionary
Don Arnold" <email@example.com
Sat Apr 19 09:24:01 2003
----- Original Message -----
From: "reavey" <firstname.lastname@example.org>
Sent: Saturday, April 19, 2003 7:39 AM
Subject: [Tutor] back-quotes to print dictionary
> I found this in instant python tutorial and I'm not sure how it's
> suposed to work?
> #!/usr/bin/env python
> class Basket:
> def __init__(self, contents = None):
> self.contents = contents or 
> def add(self,element):
> def print_me(self):
> result = ""
> for elem in self.contents:
> result = result + " " +`element`
> print "contains:" +result
You have a typo in print_me(). Although you're iterating through
self.contents using elem, you're appending `element` to the result. Change
one of them so they match and it should work.