-1

I am opening a .csv file that contains links and I want to navigate to each one. But when i print the list of links, it has brackets and single quotes around them. How do I print the links without the brackets and single quotes?

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(i)

Results

['https://links.com/100GLC-PFAQ-6X9?idc=43']
['https://links.com/100GLC-PFAQ-9X12?idc=43']
['https://links.com/100LB-PFLIN-9X12?idc=43']
['https://links.com/14PT-PFUV-5.25X10.5?idc=43']
['https://links.com/14PT-PFUV-6X9?idc=43']
['https://links.com/14PT-PFUV-9X12?idc=43']

UPDATE I solved the issue using the *. Below is my updated code.

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(*i)
Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
BigEfromDaBX
  • 157
  • 1
  • 2
  • 10

2 Answers2

0

I solved the issue using the *. Below is my updated code.

import csv
import os

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links = list(reader)

for i in links:
    print(*i)
BigEfromDaBX
  • 157
  • 1
  • 2
  • 10
-1

You could do next:

import csv
import os

links = []

with open('links.csv', 'r') as f:
  reader = csv.reader(f)
  links.extend(reader)

print(links) # show all links without for loop
alex2007v
  • 1,230
  • 8
  • 12