Ex 24: Tuple and list

Based on my limited knowledge about Python, “formula” is of the type tuple within this example. Then why is it being referred to as a list in the comments? Or is there something else?
PS: The comment after return statement is added by me and that after declaring “formula” variable is from the book LPTHW.

Yes that’s not a hundred percent precise. But don’t bother. This works for any iterable, that is, any object that has the form of a sequence where you can read things one by one.

1 Like

Are iterable objects separated by commas, like list and tuples?

1 Like

Basically yes. Also strings, dictionaries, generators… If you’re interested, google “Python iterator protocol”.

A free service run by Zed A. Shaw for learncodethehardway.org.