¡GoConqr estrena diseño! Cuéntanos qué te parece.

Apuntes

Python

Sital Sitoula Inglés 1 página

Contenido del apunte (1)

Página 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)

Información

Descripción
Apunte sobre Python, creado por Sital Sitoula el 15/05/2019.
Creado por
Sital Sitoula
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?