On 06/10/16 15:15, Zeel Solanki wrote: > def filter_long_words(words, n): > for x in words.split(): > return filter(lambda x: len(x) > n, words)
You are trying to be too clever here, you don't need the loop. words is the original string so your filter will only receive the full string each time. But you can remove the loop and just use: return filter(lambda x: len(x) > n, words.split()) Bob has already addressed your problem of reading n from raw_input(). BTW Nowadays this would more commonly be done using a list comprehension rather than reduce. I don't know if you have covered comprehensions yet? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor