[Tutor] Coma separated instead TAB separated

Mario Py mariopy at gmx.com
Sun Jun 8 20:56:40 CEST 2014


Hi everyone, this is very basic/beginner question.

I'm reading TXT file, two words per line that are separated by TAB:

question, rightAnswer = line.strip().split('\t')

I would like to use TXT file that it would be separated by coma.
How do I change that line of code?

I tried these two versions but it is not working:

question, rightAnswer = line.strip().split('\c')    # c for coma?
question, rightAnswer = line.strip().split('\,')    # , for coma?

I have latest Python version.



More information about the Tutor mailing list