The question is basically asking me to write a two-dimensional array that stores a band name and the number of sales they have. Then it asks me to write a program that sorts the list using bubble sort in ascending order according to the number of sales. The first two parts are fairly simple and are working fine. However, it later asks me to allow it to let the user enter a name of a band and be given their chart position using a linear search. This is the part I am struggling with.
myList = [[53,"band1"],[26,"band2"],[923,"band3"],[31,"band4"],[44,"band5"],
[55,"band6"],[231,"band7"]]
def bubbleSort(myList):
for passnum in range(len(myList)-1,0,-1):
for i in range(passnum):
if myList [i]>myList[i+1]:
top7 = myList[i]
myList[i] = myList[i+1]
myList[i+1] = top7
x = int(input("Enter a band name: "))
found = False
for i in range(len(myList)):
if(myList[i] == x):
found = True
print("%d found at %dth position"%(x,i))
break
if(found == False):
print("%d is not in list"%x)
bubbleSort(myList)
print(myList)
this is the output: Enter a band name: band4 Traceback (most recent call last): File "python", line 10, in ValueError: invalid literal for int() with base 10: 'band4'