GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

Python

Sital Sitoula Englisch 1 Seite

Inhalt der Notizen (1)

Seite 1

Lists

- The LIst is like an array but can contain many data types.

Creating Lists:

# Python program to demonstrate

# Creation of List

# Creating a List

List = []

print("Intial blank List: ")

print(List)

# Creating a List with

# the use of a String

List = ['GeeksForGeeks']

print("\nList with the use of String: ")

print(List)

# Creating a List with

# the use of multiple values

List = ["Geeks", "For", "Geeks"]

print("\nList containing multiple values: ")

print(List[0])

print(List[2])

# Creating a Multi-Dimensional List

# (By Nesting a list inside a List)

List = [['Geeks', 'For'] , ['Geeks']]

print("\nMulti-Dimensional List: ")

print(List)

# Creating a List with

# the use of Numbers

# (Having duplicate values)

List = [1, 2, 4, 4, 3, 3, 3, 6, 5]

print("\nList with the use of Numbers: ")

print(List)

# Creating a List with

# mixed type of values

# (Having numbers and strings)

List = [1, 2, 'Geeks', 4, 'For', 6, 'Geeks']

print("\nList with the use of Mixed Values: ")

print(List)

Slicing: List[:4]

LIst methods

List . append()

List. remove(item), List.pop(index)

Informationen

Beschreibung
Notiz am Python, erstellt von Sital Sitoula am 15/05/2019.
Erstellt von
Sital Sitoula
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck