[Tutor] problem with using set

Praveen Singh c2praveen30jun at gmail.com
Thu Oct 13 16:44:53 CEST 2011

i have two questions-
1.>>> removeLetter("hello", "l")

To tackle this problem i am using set so that i can remove duplicates.
def removeLetter(word,letter)
????return ''.join(set(word))

I am not getting right answer.I think i am not using sets correctly.please

>>> a='hello'
>>> set(a)
set(['h', 'e', 'l', 'o']), so i am thinking somehow if i remove 'l' and i
join the string, i will get the desired output.

>>> a='microsoft'
>>> set(a)
set(['c', 'f', 'i', 'm', 'o', 's', 'r', 't'])
>>> print ''.join(set(a))

When i print "Hello", i get the output as "helo"(in same sequence) but when
i write "microsoft" i get this-"cfimosrt". So, it means i can't predict the
outcome of set(a)??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111013/e29ad005/attachment.html>

More information about the Tutor mailing list