I just started learning Python... I am writing a simple program that will take in integers and keep an unsorted and sorted list. I m having a problem with the sorted list part... I m getting an error when comparing the values of elements within the list. Where I get the error is the following line: "if sortedList[sortcount] > sortedList[count]:". I get "TypeError: unorderable types: list() > int()".
这里是法典的一部分...... 我不相信什么是错的。
numberList = []
sortedList = []
count = 0
sum = 0
....(skip)....
sortcount = 0
sortedList += [ int(userInput) ]
while sortcount < count:
if sortedList[sortcount] > sortedList[count]:
sortedList[count] = sortedList[sortcount]
sortedList[sortcount] = [ int(userInput) ]
sortcount+=1