This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Listas no Python | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
print(lista_bandas) #["Metallica","AC/DC","The Who","Ramones"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nested List | |
lista_bandas_genero = ["Rock", ["Metallica","AC/DC","Ramones"]] | |
print(lista_bandas_genero) #['Rock', ['Metallica', 'AC/DC', 'Ramones']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Acessar um elemento específico da lista | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
banda_metallica = lista_bandas[0] #índice 0 = Metallica | |
print(banda_metallica) #Metallica |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Alterar um item da Lista Python | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
lista_bandas[3] = "The Beatles" #Acessa elemento de índice 3 e altera o valor do item | |
print(lista_bandas) #Alterado a banda Ramones por The Beatles ['Metallica', 'AC/DC', 'The Who', 'The Beatles'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Adicionar um item na Lista Python | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
lista_bandas.append("The Beatles") #Adiciona a banda The Beatles na lista de bandas | |
print(lista_bandas) #['Metallica', 'AC/DC', 'The Who', 'Ramones', 'The Beatles'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Adicionar um item na Lista Python na primeira posição | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
lista_bandas.insert(0, "The Beatles") #Adiciona a banda The Beatles na primeira posição da lista | |
print(lista_bandas) #['The Beatles', 'Metallica', 'AC/DC', 'The Who', 'Ramones'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Remove um item na lista Python | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
lista_bandas.remove("Ramones") # remove a banda Ramones da lista Python | |
print(lista_bandas) #['Metallica', 'AC/DC', 'The Who'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Remove um item na Lista Python pelo índice | |
lista_bandas = ["Metallica","AC/DC","The Who","Ramones"] | |
lista_bandas.pop(0) # remove a banda Metallica da lista Python | |
print(lista_bandas) #['AC/DC', 'The Who', 'Ramones'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Tupla no Python | |
tupla_bandas = ("Metallica","AC/DC","The Who","Ramones") | |
print(type(tupla_bandas)) #tuple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Acessa um item da tupla no Python | |
tupla_bandas = ("Metallica","AC/DC","The Who","Ramones") | |
banda_metallica_tupla = tupla_bandas[0] # acessa o elemento da posição 0 "Metallica" | |
print(banda_metallica_tupla) #Metallica |
OlderNewer