Open essepuntato opened 3 years ago
hp_list = list() hp_list.append("Draco") hp_list.append("Harry") hp_list.append("Hermione") hp_list.append("Ron") hp_list.append("Severus") print (hp_list)
FIRST METHOD
hp_list= list()
hp_list.append("Draco")
hp_list.append("Harry")
hp_list.append("Hermione")
hp_list.append("Ron")
hp_list.append("Severus")
print (hp_list)
SECOND METHOD
hp1_list= ["Draco", "Harry", "Hermione", "Ron", "Severus"]
print (hp1_list)
THIRD METHOD
hp2_list= list()
hp2_list.append("Harry")
hp2_list.append("Severus")
hp2_list.append("Hermione")
hp2_list.append("Ron")
hp2_list.append("Draco")
hp2_list.sort()
print(hp2_list)
my_list_hp=list()
my_list_hp.append("Draco")
my_list_hp.append("Harry")
my_list_hp.append("Hermione")
my_list_hp.append("Ron")
my_list_hp.append("Severus")
print(my_list_hp)
my_list= list() my_list.append("Harry") my_list.append("Draco") my_list.append("Hermione") my_list.append("Severus") my_list.append("Ron") my_list.sort() print(my_list)
lista_hp = list['Draco', 'Harry', 'Hermione', 'Ron', 'Severus'] print(lista_hp)
#FIRST METHOD
Harry_potter_list = list()
Harry_potter_list.append("Draco")
Harry_potter_list.append("Harry")
Harry_potter_list.append("Hermione")
Harry_potter_list.append("Ron")
Harry_potter_list.append("Severus")
print(Harry_potter_list)
#SECOND METHOD
Harry_potter_list = list()
Harry_potter_list.append("Hermione")
Harry_potter_list.append("Draco")
Harry_potter_list.append("Severus")
Harry_potter_list.append("Ron")
Harry_potter_list.append("Harry")
Harry_potter_list.sort()
print(Harry_potter_list)
#THIRD METHOD
Harry_potter_list = ["Draco", "Harry", "Hermione", "Ron", "Severus"]
print(Harry_potter_list)```
my_list = list()
my_list.append("Draco")
my_list.append("Harry")
my_list.append("Hermione")
my_list.append("Ron")
my_list.append("Severus")
print(my_list)
#with user input
names_list = input('Enter each name separed by a comma: ').split(', ')
print(sorted(names_list))
#without user input
names_list = list()
names_list.append("Severus")
names_list.append("Harry")
names_list.append("Ron")
names_list.append("Hermione")
names_list.append("Draco")
print(sorted(names_list))
my_list = list() my_list.append("Draco") my_list.append("Harry") my_list.append("Hermione") my_list.append("Ron") my_list.append("Severus")
print(my_list)
harry_potter_names = list()
harry_potter_names.append("Draco")
harry_potter_names.append("Harry")
harry_potter_names.append("Hermione")
harry_potter_names.append("Ron")
harry_potter_names.append("Severus")
my_hp_list = list() my_hp_list.append("Draco") my_hp_list.append("Harry") my_hp_list.append("Hermione") my_hp_list.append("Ron") my_hp_list.append("Severus")
print(my_hp_list)
hp_list = list()
hp_list.append("Draco")
hp_list.append("Harry")
hp_list.append("Hermione")
hp_list.append("Ron")
hp_list.append("Severus")
print(hp_list)
hogwarts_list = list()
hogwarts_list.append("Draco")
hogwarts_list.append("Harry")
hogwarts_list.append("Hermione")
hogwarts_list.append("Ron")
hogwarts_list.append("Severus")
print(hogwarts_list)
my_list = list()
my_list.append("Draco")
my_list.append("Harry")
my_list.append("Hermione")
my_list.append("Ron")
my_list.append("Severus")
print(my_list)
harry_list = list() harry_list.append("Harry") harry_list.append("Severus") harry_list.append("Hermione") harry_list.append("Ron") harry_list.append("Draco") harry_list.sort() print(harry_list)
potter_list= list() potter_list.append("Draco") potter_list.append("Harry") potter_list.append("Hermione") potter_list.append("Ron") potter_list.append("Severus") print (potter_list)
mylist = []
mylist.append("harry")
mylist.append("draco")
mylist.append("hermione")
mylist.append("ron")
mylist.append("severus")
print(mylist)
harry_potter_list = list()
harry_potter_list.append("Draco")
harry_potter_list.append("Harry")
harry_potter_list.append("Hermione")
harry_potter_list.append("Ron")
harry_potter_list.append("Severus")
print(harry_potter_list)
HP_list = list()
HP_list.append("Harry")
HP_list.append("Draco")
HP_list.append("Hermione")
HP_list.append("Ron")
HP_list.append("Severus")
HP_list.sort()
print(HP_list)
HPE=list()
HPE.append("Draco")
HPE.append("Harry")
HPE.append("Hermione")
HPE.append("Ron")
HPE.append("Severus")
print(HPE)
potter_list = [] potter_list.append("Harry") potter_list.append("Draco") potter_list.append("Hermione") potter_list.append("Ron") potter_list.append("Severus") potter_list.sort() print(potter_list)
hp_list = list()
hp_list.append('Harry') hp_list.append("Draco") hp_list.append("Hermione") hp_list.append("Ron") hp_list.append("Severus") hp_list.sort()
print(hp_list)
hp_characters = ["Hermione", "Ron", "Draco", "Harry"]
hp_characters.append("Severus")
hp_characters.sort()
Write a sequence of instructions in Python to create a list with the following elements ordered alphabetically:
"Harry"
,"Draco"
,"Hermione"
,"Ron"
,"Severus"
.