[Tutor] dictionary
Steven D'Aprano
steve at pearwood.info
Fri May 6 05:05:51 CEST 2011
louis leichtnam 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.
d = {1: "Hello world", 2: "My name is Xavier", 3: "ham and eggs",
4: "Eat more cheese please!", 5: "spam spam spam spam spam spam",
6: "how much wood would a woodchuck chuck if a woodchuck would"
" chuck wood?", 7: "nice cup of tea and a slice of cake"}
for value in d.values():
if value.count(" ") >= 3:
print(value)
--
Steven
More information about the Tutor
mailing list