/
diev
/
swaroopch-byte-of-python
Обзор
Документация
Войти
/
diev
/
swaroopch-byte-of-python
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
programs/ds_reference.py
23 строки
657 B
Swaroop C H
Add programs folder
19 янв 2016, 18:47
19 янв 2016, 18:47
ed99d1b
Код
Авторство
О чём код?
print('Simple Assignment') shoplist = ['apple', 'mango', 'carrot', 'banana'] # mylist is just another name pointing to the same object! mylist = shoplist # I purchased the first item, so I remove it from the list del shoplist[0] print('shoplist is', shoplist) print('mylist is', mylist) # Notice that both shoplist and mylist both print # the same list without the 'apple' confirming that # they point to the same object print('Copy by making a full slice') # Make a copy by doing a full slice mylist = shoplist[:] # Remove first item del mylist[0] print('shoplist is', shoplist) print('mylist is', mylist) # Notice that now the two lists are different