# Indexing and Slicing Strings

## Escape sequences:

```python
 \n # Prints on new line
```

## Indexing:

```python
sentence = 'this is a sentence'

# to print t
print(sentence[0])

# to print last
print(sentence[-1])
```

## String slicing:

```python
# to get the first word
print(sentence[0:4]) # prints 0 to 3
# prints this
```

## Slinging the data in increment of 2 (every other char)

```python
sentence = 'abcdefg'
print(sentence[0:7:2]) # Last colon prints increment
# prints aceg
```

## Getting strings only from a certain point forward

```python
# don't need abc
print(sentence[3:])
#prints defg
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.arkannis.net/programming/courses/python-pcap-31-03-course/overview-and-introduction/indexing-and-slicing-strings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
