-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Organising information: ordered structures", exercise 1 #14
Comments
my_list = list () |
Approach 1 (the one mentioned above, since lists care about the order of addition):
Approach 2 (add names in any order then use .sort)
|
|
The list can be create through this Py code:
Indeed, if we execute the command |
|
|
I used the sort method to sort the list alphabetically.
|
my_hp_list = list() my_hp_list.append("Draco") print(my_hp_list) ['Draco', 'Harry', 'Hermione', 'Ron', 'Severus'] |
my_list = list () ['Draco', 'Harry', 'Hermione', 'Ron', 'Severus'] |
|
hogwarts_list = list() hogwarts_list.sort() |
harry_potter_list = list() harry_potter_list.sort() |
my_list = list() |
my _list = list() |
friends_list = list() friends_list =sorted(friends_list) print(friends_list) returns the names in alphabetical order |
harry_potter_list = list () |
Version 1 Version 2 |
my_list = ["Harry", "Draco", "Hermione", "Ron", "Severus"] |
|
Hi, just a note for @giorgimariachiara and @elizastuglik: try to run your code in Python, and see what happens. |
my_list = list () |
|
|
|
Write a sequence of instructions in Python to create a list with the following elements ordered alphabetically:
"Harry"
,"Draco"
,"Hermione"
, "Ron"
,"Severus"
.The text was updated successfully, but these errors were encountered: