[Tutor] I am teaching my students Python the second semester using www.LearnStreet.com ( http://www.learnstreet.com/ ). I am in need of some help. I am having a problem with the Lists-Set 1 exercise 18. The problem is below. I have put in several codes and the output is 5, which is the right answer. But it is asking for List's index logic. I have tried support with LearnStreet but they have yet to respond. Thank you for your time.

Danny Yoo dyoo at hashcollision.org
Tue Feb 4 19:59:02 CET 2014


The question as stated is fairly artificial and a bit nonsensical.
Let me explain that statement, because it's a strong one.

If we know the exact shape for list1 and list2 are, we can answer this
question directly, without loops.

    len(list1[-1])

"Take the last element of the list1, and grab its length."

Note: no loops, no if statements.  It's the direct solution to this
problem as stated.


You need lists and loops when you're working with data of some dynamic
size that can vary.  But this problem doesn't demonstrate that need at
all, so as far as I can tell.  And there's no need for 'if' statements
here either with the original problem statement.  Again, the problem
as stated is so static, so anemic, that there's no need for any
branching, conditional logic.

Hence the problem does not seems like a good question to ask.  It's
likely nonsensical to a professional programmer, and likely
nonsensical to your students as well.  If yo can, try to find a better
source of good questions.  Your students will be happier.


More information about the Tutor mailing list