[Tutor] dictionary

naheed arafat naheedcse at gmail.com
Fri May 6 04:45:06 CEST 2011


Supposing your dictionary like this: dict={1:'My name is X',2:'My name is x
y z',3: 'i am X'}
You can use len(list) :
>>> dict={1:'My name is X',2:'My name is x y z',3: 'i am X'}
>>> for values in dict.values():
...      if len(values.split(' '))>3:
...        print values
My name is X
My name is x y z

On Fri, May 6, 2011 at 7:56 AM, louis leichtnam <l.leichtnam at gmail.com>wrote:

> HEllo everyone,
>
> I have a dictionnary, and I would like to print only the values that have
> more/equal than 3 spaces in them for example: My name is Xavier.
>
> Can you help me out,
>
> Thanks
>
> Louis
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110506/ed8a04bb/attachment.html>


More information about the Tutor mailing list