Python Tutorial | Python List | Add Items in the list | Remove Items in list | Join Items in List

Veröffentlicht am: 01 Januar 1970
auf dem Kanal: GSS
142
2

In this video, You will learn Python Programming Language.

Python List
"# Add Items in the list:"
"# append() method: add a item to the end of list"
Mylist = [10, "India", -50, 30.22, True ]
Mylist.append("Delhi")
Mylist.append(100)
print(Mylist)

"# insert method: add item to the specific index"
Mylist = [10, "India", -50, 30.22, True]
Mylist.insert(1, "USA")
print(Mylist)

"# Remove Items in list:"
"# remove method: specific item will be removed"
"# If duplicate items are present in the list then" \
"remove method will remove first item in the list"
Mylist = [10, "India", -50, 30.22, True, 10, 10]
Mylist.remove(10)
Mylist.remove(True)
print(Mylist)

"# pop method: remove specific index from list"
Mylist = [10, "India", -50, 30.22, True, 10, 10]
x = Mylist.pop(1)
print(Mylist)
y = Mylist.pop(3)
print(Mylist)

"# In pop method, if you do not specify the index then" \
"it remove the last item from the list"
Mylist = [10, "India", -50, 30.22, True]
Mylist.pop()
print(Mylist)

"# clear method: empty the list"
Mylist = [10, "India", -50, 30.22, True]
Mylist.clear()
print(Mylist)

"# Copy Items in List:"
"# copy method: Will copy list from one to another"
Mylist = [10, "India", -50, 30.22, True]
CopyMylist = Mylist.copy()
print(CopyMylist)

"# list method:"
Mylist = [10, "India", -50, 30.22, True]
CopyMylist = list(Mylist)
print(CopyMylist)

"# Join Items in List:"
"# Using + Operator:"
city = ["Lucknow", "Mumbai", "Bangalore"]
state = ["UP", "Maharastra", "Karnataka"]
address = city + state
print(address)

"# append method:"
city = ["Lucknow", "Mumbai", "Bangalore"]
state = ["UP", "Maharastra", "Karnataka"]
for i in state:
city.append(i)
print(city)

"# extend method"
city = ["Lucknow", "Mumbai", "Bangalore"]
state = ["UP", "Maharastra", "Karnataka"]
city.extend(state)
print(city)

"# sort method: arrange values in ascending order"
Pincode = [10,20,30, 90, 60, 40, 80, 30]
Pincode.sort()
print("Asending:", Pincode)
Pincode.sort( reverse=10)
print("Descending:",Pincode)

"# reverse method"
Pincode = [10,20,30, 90, 60, 40, 80, 30]
Pincode.reverse()
print(Pincode)

"# Python Tuples:"
See the next video...


Auf dieser Seite können Sie das Online-Video Python Tutorial | Python List | Add Items in the list | Remove Items in list | Join Items in List mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer GSS 01 Januar 1970 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 142 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!