On 06/10/16 17:50, Alan Gauld via Tutor wrote:
> Nowadays this would more commonly be done using a list
> comprehension rather than reduce.
Sorry, I meant filter() not reduce().
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Fo
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
On 10/6/2016 10:15 AM, Zeel Solanki wrote:
def filter_long_words(words, n):
for x in words.split():
return filter(lambda x: len(x) > n, words)
print filter_long_words(raw_input("Enter a list of words with spaces in
between."), raw_input("Enter a number."))
raw_input() always returns a st
On 10/6/2016 10:15 AM, Zeel Solanki wrote:
def filter_long_words(words, n):
for x in words.split():
return filter(lambda x: len(x) > n, words)
print filter_long_words(raw_input("Enter a list of words with spaces in
between."), raw_input("Enter a number."))
raw_input() always returns a st
Hello,
I am a grade 11 high school student and I am having a hard time solving the
problem below. I have been stuck on it for days and I would like some
guidance from you.
The Problem:
Write a function filter_long_words() that takes a list of words and an
integer n and returns the list of words th