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.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to