So I'm making a code where it asks the user to to swap two places on the list until the list is from smallest to biggest. So it should look like this:
Hello: Your current list is [6, 7, 8, 2 , 9, 10, 12, 15, 16, 17]
Please pick your first location -> 4
Please pick your second location -> 2
Your new list is [6, 2, 8, 7 , 9, 10, 12, 15, 16, 17]
I've gotten to this part but I am currently unable to figure out how to get the user to do the sorting and not the code.
Your list is not sorted: Please continue
Please pick your first location -> 1
Please pick your second location -> 2
Your new list is [2, 6, 8, 7 , 9, 10, 12, 15, 16, 17]
Please pick your first location -> 3
Please pick your second location -> 4
Your new list is [2, 6, 7, 8 , 9, 10, 12, 15, 16, 17]
Great job, thank you for sorting my list.
Here is my code:
list = [4,2,5,5,6,4,7,6,9,5]
print("Heres your current list", list)
print("Pick a location between 1 and 10")
num = int(input())
if num <= 10 and num >= 1:
print("Please pick another location between 1 and 10")
num1 = int(input())
tempBox1 = list[num-1]
tempBox2 = list[num1-1]
list[num-1] = tempBox2
list[num1-1] = tempBox1
print("Your new list is", list)