I have a Python program, which reads text from a file copied from the Internet and stores it in a variable for further use. It is very simple and goes like this:
Line=(Storefile.readline())
Word=Line[:-1]
([:-1] to get rid of the carriage return symbol ('\n'))
If I write Word in IDLE it returns - 'bread'
All works well, untill the read line has an apostrophe in it. In which case writing Word in IDLE gives - "bread's". 'bread' versus "bread's" - single vs. double quotes
If I compose the Word variable on a char by char basis:
for n in range(len(Word)):
Word=Word+Word[n]
The moment Word[n] is the apostrophe - single quotes turn to double quotes. 'bread' vs "bread'".
And the question is - how can I convert double quotes to a single quote? Word.replace() doesn't work, because the quotes are not part of the string - I'm at a loss...