Nym City via Tutor wrote:

>  import csv
> DomainList = []
> 
> domains = open('domainlist.csv', 'r')
> DomainList = csv.reader(domains)
> DomainList = [column[1] for column in DomainList]
> DomainList = (str(DomainList).rstrip('/')
> print('\n'.join(DomainList))
> 
> 
> I keep getting EOL error on the second the last line and syntax error on
> the last print line. Even when I change the print line to say the
> following: print(DomainList) Please advise. Thank you in advance.
> Thank you.

Look at the lines preceding the one triggering the SyntaxError. Usually 
there is an opening (, [ or { which doesn't have a matching closing 
counterpart. 

In your case count the parens in the line

> DomainList = (str(DomainList).rstrip('/')

By the way, even without error this line will not have the desired effect.
Given 

>>> DomainList = ["facebook.com/", "twitter.com/"]

converting to string gives

>>> str(DomainList)
"['facebook.com/', 'twitter.com/']"

and as that doesn't end with a "/" applying the rstrip() method has no 
effect. Instead you can modify the line

> DomainList = [column[1] for column in DomainList]

where you can invoke the rstrip() method on every string in the list.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to