how would I get a list that looks like this:
[‘3’, ‘2’]
to this:
32
I have an inventory and if I save it straight from list to string, when it loads it thinks the brackets and quotes are items on the list.
Thanks!
One way to do that:
list = ['3', '2']
string = ""
for i in list:
string += i
print string # 32
I have an inventory and if I save it straight from list to string, when it loads it thinks the brackets and quotes are items on the list.
Thanks!
I recommend saving the datastructure itself, rather than converting to store in form of pure string.
Google “python pickle”, I think it’s what you’re looking for.
Also, you may want to do some research on using a python “dictionary”. It could serve as a more versatile structure (which is hard to believe, I know, since lists themselves are damn near magic as they are).
Another way to do it is:
list = ["3", "2"]
string = "".join(list)
print string
That will print “32”.
Ahh, that’s right.
Thanks Chaser, good to know.
thank you! I’ll look up pickle.