- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Python's reverse vs reversed 2minutespy
Get Free GPT4o from https://codegive.com
sure! let's explore the differences between python's `reverse()` method and the `reversed()` function.
### overview
- **`list.reverse()`**: this is a method that modifies a list in place, meaning it changes the original list and does not return a new list.
- **`reversed()`**: this is a built-in function that returns an iterator that accesses the given sequence in the reverse order without modifying the original sequence.
### key differences
1. **return type**:
- `list.reverse()` returns `none` since it modifies the list in place.
- `reversed()` returns an iterator, which can be converted to a list or used in loops.
2. **modifying original**:
- `list.reverse()` modifies the original list.
- `reversed()` does not modify the original sequence.
3. **supported types**:
- `list.reverse()` is specific to lists.
- `reversed()` can work with any iterable, such as strings, tuples, and lists.
### code examples
here are examples to illustrate the differences:
#### using `list.reverse()`
**output:**
#### using `reversed()`
**output:**
### summary
- use `list.reverse()` when you want to reverse a list in place and do not need to keep the original order.
- use `reversed()` when you want a new reversed sequence while keeping the original sequence intact.
that's a quick overview of `reverse()` vs `reversed()` in python!
...
#python reverse shell
#python reverse list
#python reverse for loop
#python reverse range
#python reverse list order
python reverse shell
python reverse list
python reverse for loop
python reverse range
python reverse list order
python reverse string
python reversed
python reverse array
python reverse sort
python reverse dictionary
python reversed function
python reverse list
python reverse shell
python reverse string
python reversed time complexity
python reversed
python reversed range
python reversed for loop
Видео Python's reverse vs reversed 2minutespy канала CodeIgnite
sure! let's explore the differences between python's `reverse()` method and the `reversed()` function.
### overview
- **`list.reverse()`**: this is a method that modifies a list in place, meaning it changes the original list and does not return a new list.
- **`reversed()`**: this is a built-in function that returns an iterator that accesses the given sequence in the reverse order without modifying the original sequence.
### key differences
1. **return type**:
- `list.reverse()` returns `none` since it modifies the list in place.
- `reversed()` returns an iterator, which can be converted to a list or used in loops.
2. **modifying original**:
- `list.reverse()` modifies the original list.
- `reversed()` does not modify the original sequence.
3. **supported types**:
- `list.reverse()` is specific to lists.
- `reversed()` can work with any iterable, such as strings, tuples, and lists.
### code examples
here are examples to illustrate the differences:
#### using `list.reverse()`
**output:**
#### using `reversed()`
**output:**
### summary
- use `list.reverse()` when you want to reverse a list in place and do not need to keep the original order.
- use `reversed()` when you want a new reversed sequence while keeping the original sequence intact.
that's a quick overview of `reverse()` vs `reversed()` in python!
...
#python reverse shell
#python reverse list
#python reverse for loop
#python reverse range
#python reverse list order
python reverse shell
python reverse list
python reverse for loop
python reverse range
python reverse list order
python reverse string
python reversed
python reverse array
python reverse sort
python reverse dictionary
python reversed function
python reverse list
python reverse shell
python reverse string
python reversed time complexity
python reversed
python reversed range
python reversed for loop
Видео Python's reverse vs reversed 2minutespy канала CodeIgnite
Комментарии отсутствуют
Информация о видео
22 августа 2024 г. 9:02:15
00:06:49
Другие видео канала
