-3

I have an external .csv file which I read into a 2 dimensional list, sort it, then print it. I don't want the square brackets when it prints, how do I get rid of them?

def bubbleSort(hi):
    for passnum in range(len(hi)-1,0,-1):
        for i in range(passnum):
            if hi[i]>hi[i+1]:
                temp = hi[i]
                hi[i] = hi[i+1]
                hi[i+1] = temp

hi =[]

with open('winners.csv', 'r') as textfile:
    for row in reversed(list(csv.reader(textfile))):

        #create the file into an array

        hi.append(row)

#initiate the bubble sort on the array 

bubbleSort(hi)

# print the top 5 winners

for i in range(5):
    print(hi[i])

gives the output:

[score, name]
[score, name]
[score, name]
[score, name]
[score, name]

i would just like to be rid of the brackets if possible. so it looks like:

score, name
score, name
score, name
score, name
score, name
dman112
  • 1
  • 3

1 Answers1

0

You have a few options if this is just to print the contents at the once your code is completed.

lista = [1, 2, 3]

print(' '.join([str(i) for i in lista]))
print(*lista)
for i in lista:
    print(i, end = ' ')
1 2 3
vash_the_stampede
  • 4,590
  • 1
  • 8
  • 20