Re: [Tutor] (no subject)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 23:16, Zeel Solanki wrote: > HelloI just started using python and my teacher has given us some problem I just noticed that you are the same person who posted earlier. The replies you have already received should answer your questions. Please don't start a second thread with the same s

Re: [Tutor] (no subject)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 23:16, Zeel Solanki wrote: > HelloI just started using python and my teacher has given us some problem > to solve and I am having some problem soving the question below. I have > written some part of the code already, so can u please correct the code for > me to make it work. Please and

[Tutor] (no subject)

2016-10-06 Thread Zeel Solanki
HelloI just started using python and my teacher has given us some problem to solve and I am having some problem soving the question below. I have written some part of the code already, so can u please correct the code for me to make it work. Please and thank you. Question: Write a function filter_

Re: [Tutor] Python Word Problems(Student)

2016-10-06 Thread Alan Gauld via Tutor
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

Re: [Tutor] Python Word Problems(Student)

2016-10-06 Thread Alan Gauld via Tutor
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

Re: [Tutor] Python Word Problems(Student) MORE ISSUES

2016-10-06 Thread bob gailer
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

Re: [Tutor] Python Word Problems(Student)

2016-10-06 Thread bob gailer
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

[Tutor] Python Word Problems(Student)

2016-10-06 Thread Zeel Solanki
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