# Python String Length and Indexing Guide | len() & Indexes
> Master Python strings with this guide on the len() function, zero-based indexing, negative indexes, and avoiding common IndexError exceptions.

Tags: python, string-methods, coding-basics, programming-tutorial, len-function, indexerror
## הפונקציה len() בפייתון
* פונקציה מובנית המחזירה את אורך המחרוזת.
* `len("Hello")` מחזירה 5.
* סופרת את כל התווים כולל רווחים וסימנים.

## Python Indexing Basics
* String indexes start at 0.
* Characters are accessed using the syntax `word[index]`.
* For "Python", index 0 is 'P' and index 2 is 't'.

## Negative Indexes
* Allows access to string characters from the end.
* `word[-1]` is the last character, `word[-2]` is the second to last.

## הקשר בין len() לאינדקסים
* הנוסחה לאינדקס האחרון היא תמיד `len(word) - 1`.
* גישה לאינדקס השווה לאורך המחרוזת תגרום לשגיאה.

## Common Error: IndexError
* Occurs when trying to access an index that is out of bounds.
* Example: In the word "Hi", index 2 does not exist and will raise `IndexError: string index out of range`.
---
This presentation was created with [Bobr AI](https://bobr.ai) — an AI presentation generator.