From 7a934e48f12b06205bec0313477669f494e1330b Mon Sep 17 00:00:00 2001 From: sophiewax Date: Sun, 2 Feb 2025 23:08:30 -0500 Subject: [PATCH] Update lists.ipynb --- lists.ipynb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lists.ipynb b/lists.ipynb index 38de076..11d165e 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -1043,3 +1043,18 @@ "nbformat": 4, "nbformat_minor": 2 } + +places = ["China", "Korea", "France", "Brazil", "Costa Rica"] #places to visit +print("Original List:", places) #printed original list +print("Alphabetical order:", sorted(places)) #print alphabetical list +print("Still original list:", places) #show list in original order by printeing it +print("Reverse alphabetical order:", sorted(places, reverse=True)) #print in reverse alphabetical order +print("Still original list:", places) #show list in original order by printeing it +places.reverse() #use reverse to change over of list +print("Reversed list:", places) #print to show order has changed +places.reverse() #use reverse to change over of list again +print("Back to original order:", places) #print to show order is back to original +places.sort() #sort list alphabetically +print("Permanently sorted list:", places) #print to show above is true +places.sort(reverse=True) #store in reverse alphabetical order +print("Permanently reverse sorted list:", places) #print to make sure above is true