I have a file with level, equation and answer (separated by tabs), for a math game. For example:
Lvl Eq Ans 2 2*6 12 How can I replace the tab space by a comma , in a new file?
I have a file with level, equation and answer (separated by tabs), for a math game. For example:
Lvl Eq Ans 2 2*6 12 How can I replace the tab space by a comma , in a new file?
Use the str.replace() method like this:
>>> s = '2\t2*6\t12' >>> print s 2 2*6 12 >>> s.replace('\t', ',') 2,2*6,12