0

How can I find the index of a back slash within a string?

f = open("newFile.txt", "w+") pathName = os.path.abspath(f.name) index = pathName.find(r"\") <-- This needs fixing

30th May 2020, 7:09 PM
Jeremy Cruz
Jeremy Cruz - avatar
1 Answer
+ 7
You should use a double backslash, that's all. ...find("\\") just make sure it is the right slash, as you will encounter the regular one in Linux and in Sololearn most likely.
30th May 2020, 7:13 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar