Hi. I am currently working on a project for myself. The code posted here is supposed to ask the user for an amount of numbers, what those numbers are, and places those numbers in a list. The next job of the code is to sort the list of numbers that were inputted in an ascending fashion. There is no error from the code, however, when I run the code the first inputted number stays in its place and doesn't get sorted with the rest of the numbers. Any advice???
emptyList = [] nOFN = int(input("how many numbers do you want to sort: ")) for x in range(nOFN): number1 = int(input("input number: ")) emptyList.append(number1) firstElement = emptyList[0] n = len(emptyList) for j in range(1, n): if emptyList[j-1] > emptyList[j]: (emptyList[j-1], emptyList[j]) = (emptyList[j], emptyList[j-1]) print(emptyList) Sent from an email account _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor