<div dir="ltr"><div>Hi Everyone,</div>
<div> </div>
<div>I am trying to read a comma-delimitted list ("aaa","bbb","ccc") from a text file and assign those values to a list, x, such that:</div>
<div> </div>
<div>x = ["aaa", "bbb", "ccc"]</div>
<div> </div>
<div>The code that I have come up with looks like this:</div>
<div> </div>
<div>>>> x = []<br>>>> f = open(r'c:\test.txt', 'r')<br>>>> x.extend(f.readlines())<br>>>> x<br>['"aaa","bbb","ccc"']</div>
<div> </div>
<div>If you look closely, there is an extra pair of single quotes (') that encapsulates the string. Therefore, len(x) returns 1, instead of 3. Is there a function to "separate" this list out? I hope my question makes sense.</div>
<div> </div>
<div>Thanks in advance.</div>
<div> </div>
<div>Samir</div>
<div> </div>
<div> </div></div>