A list of size X has X items, located at list[0] to list[X-1].
The problem isn't about checking the size; it's about accessing an object that doesn't exist, namely list[X]. You put "i < list.size()" because when "i == list.size()", you've passed the list. Thus, it stops when it reaches list.size().