I have a list l1=['hi','hello',23,1.23]
.
I want to write the text ['hi','hello',23,1.23]
inside a text file, ie, the value of list as it is.
Simple
with open('f1.txt','w') as f:
f.write(l1)
doesn't work, so I tried this
f=open('f1.txt','w')
l1=map(lambda x:x+',', l1)
f.writelines(l1)
f.close()
But this doesn't work either. It says
TypeError: unsupported operand type(s) for +: 'int' and 'str'
.
How to accomplish this when list contains numbers, alphabets and float?