PYTHON_SOLVES Telegram 53
## Основные методы списков и словарей

Тема:
Как быстро добавлять, удалять и изменять данные в коллекциях.

# Работа со списками
fruits = ["яблоко", "банан"]

fruits.append("вишня")
print(fruits) # Вывод: ['яблоко', 'банан', 'вишня']

fruits.insert(1, "груша")
print(fruits) # Вывод: ['яблоко', 'груша', 'банан', 'вишня']

fruits.remove("банан")
print(fruits) # Вывод: ['яблоко', 'груша', 'вишня']

popped = fruits.pop()
print(popped) # Вывод: вишня
print(fruits) # Вывод: ['яблоко', 'груша']

# Работа со словарями
person = {"name": "Аня", "age": 25}
print(person.keys()) # Вывод: dict_keys(['name', 'age'])
print(person.values()) # Вывод: dict_values(['Аня', 25])
print(person.items()) # Вывод: dict_items([('name', 'Аня'), ('age', 25)])

person["city"] = "Москва"
print(person) # Вывод: {'name': 'Аня', 'age': 25, 'city': 'Москва'}


Полезные советы:

* .append(), .insert(), .remove() удобны для списков.
* Словари позволяют быстро находить данные по ключу.
* .pop() полезен для работы со стэками или очередями.

#азы



tgoop.com/python_solves/53
Create:
Last Update:

## Основные методы списков и словарей

Тема:
Как быстро добавлять, удалять и изменять данные в коллекциях.

# Работа со списками
fruits = ["яблоко", "банан"]

fruits.append("вишня")
print(fruits) # Вывод: ['яблоко', 'банан', 'вишня']

fruits.insert(1, "груша")
print(fruits) # Вывод: ['яблоко', 'груша', 'банан', 'вишня']

fruits.remove("банан")
print(fruits) # Вывод: ['яблоко', 'груша', 'вишня']

popped = fruits.pop()
print(popped) # Вывод: вишня
print(fruits) # Вывод: ['яблоко', 'груша']

# Работа со словарями
person = {"name": "Аня", "age": 25}
print(person.keys()) # Вывод: dict_keys(['name', 'age'])
print(person.values()) # Вывод: dict_values(['Аня', 25])
print(person.items()) # Вывод: dict_items([('name', 'Аня'), ('age', 25)])

person["city"] = "Москва"
print(person) # Вывод: {'name': 'Аня', 'age': 25, 'city': 'Москва'}


Полезные советы:

* .append(), .insert(), .remove() удобны для списков.
* Словари позволяют быстро находить данные по ключу.
* .pop() полезен для работы со стэками или очередями.

#азы

BY Python решает 🐍


Share with your friend now:
tgoop.com/python_solves/53

View MORE
Open in Telegram


Telegram News

Date: |

In the “Bear Market Screaming Therapy Group” on Telegram, members are only allowed to post voice notes of themselves screaming. Anything else will result in an instant ban from the group, which currently has about 75 members. A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create.” The best encrypted messaging apps While the character limit is 255, try to fit into 200 characters. This way, users will be able to take in your text fast and efficiently. Reveal the essence of your channel and provide contact information. For example, you can add a bot name, link to your pricing plans, etc. A Telegram channel is used for various purposes, from sharing helpful content to implementing a business strategy. In addition, you can use your channel to build and improve your company image, boost your sales, make profits, enhance customer loyalty, and more.
from us


Telegram Python решает 🐍
FROM American