numbers = [2,3,1,5,7,8,9,5,4,6] 
print(numbers)
tool_1 = int(input())
tool_2 = int(input())
x = numbers.index (tool_1)
y = numbers.index (tool_2)
numbers[x] = (tool_2)
numbers[y] = (tool_1)
print(numbers)

So I want this code to run until the numbers list is in this exact order 1,2,3,4,5,6,7,8,9
Is there a Do until loop or someway I can do this?

Recommended Answers

All 2 Replies

I prefer the use of the sorted() iterator (yes, this is procedural O(1*n))

for n in sorted(numbers):
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.