Reputation: 19
I have the following lists:
list = []
a = 'a'
b = 'b'
c = 2
d = 3
list.append(a)
list.append(b)
list.append(c)
list.append(d)
And I'm adding list
to a new txt file, which I want to show like that:
a,b,2,3
However, instead I'm getting:
['a','b',2,3]
How do I remove the [] and ''s?
Upvotes: 0
Views: 282
Reputation: 47
Here is something to try instead
sub output()
Dim a as string, b as string
Dim c as integer, d as integer
a = "a"
b = "b"
c = 2
d = 3
list = a & "," & b & "," & c & "," & d
end sub
this should concatenate the string data to be the value of each variable with commas between. I think the output you are getting is the reference, not the string value. so you just make the location you want the data to show up = to list.
Upvotes: 0
Reputation: 1006
Join the list with ',' separator. And then write to file.
res = ",".join(str(x) for x in list)
Upvotes: 1