Horje
python lists Code Example
python list
a1 = [1, 'x', 'y']
a2 = [1, 'x', 'y']
a3 = [1, 'x', 'y']

b = [2, 3]

a1.append(b)
a2.insert(3, b)
a3.extend(b)

print(a1)
print(a2)
print(a3
python list [:]
thislist = ["1.apple", "2.banana", "3.cherry", "4.orange", "5.kiwi", "6.melon", "7.mango"]

# thislist[starting index(including) : end index(not including)]

print(thislist[:]) #Output: ['1.apple', '2.banana', '3.cherry', '4.orange', '5.kiwi', '6.melon', '7.mango']
print(thislist[1:]) #Output: ['2.banana', '3.cherry', '4.orange', '5.kiwi', '6.melon', '7.mango']
print(thislist[:5]) #Output: ['1.apple', '2.banana', '3.cherry', '4.orange', '5.kiwi']
print(thislist[2:5]) #Output: ['3.cherry', '4.orange', '5.kiwi']
print(thislist[::3]) #Output: ['1.apple', '4.orange', '7.mango']
print(thislist[1::2]) #Output: ['2.banana', '4.orange', '6.melon']
print(thislist[1:6:3]) #Output: ['2.banana', '5.kiwi']
list python
>> variable = "PYTHON"
>> variable[2]
"T"
>> variable[-4]
"T"
list python
list = ["Facebook", "Instagram", "Snapchat", "Twitter"]
python lists
mylist = [1, 2, [3, 4, 5], 6]
print(mylist[2][0])
print(mylist[2][1])
print(mylist[2][2])
python lists
mylist = []  # creating an empty list

# appending values entered by user to list
for i in range(5):
    print("Enter value of n[", i, "]")
    mylist.append(input())

# printing final list
print(mylist)




Python

Related
plt.spines 'right' .set_visible(false) Code Example plt.spines 'right' .set_visible(false) Code Example
Binary to decimal in Python without inbuilt function Code Example Binary to decimal in Python without inbuilt function Code Example
no module named 'flask_jwt_extended' Code Example no module named 'flask_jwt_extended' Code Example
add months to date python Code Example add months to date python Code Example
import NoSuchKey in boto3 Code Example import NoSuchKey in boto3 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7