Iterate Objects of Unknown Length with a Sentinel

Learn to iterate objects of unknown length with a sentinel.

We'll cover the following

Some objects don’t have a specific length. To know their length, we need to iterate through all their elements. For example, elsewhere in this chapter we’ve seen a generator that doesn’t have a specific length. A more common example would be a C-string.

A C-string is a primitive C-array of characters, terminated with a null '\0' value.

Get hands-on with 1400+ tech skills courses.