Why is this code searching for the file instead of creating it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this code searching for the file instead of creating it?

import os, re f = open("newFile.txt", "w+") pathName = os.path.abspath(f.name) pattern = r"\\" count = list(x.start() for x in re.finditer(pattern, pathName)) os.remove(pathName) #HERE f = open("C:\\Users\\" + pathName[count[1]+1:count[2]-1] + "\\Desktop\\newFile.txt", "w+")

30th May 2020, 9:16 PM
Jeremy Cruz
Jeremy Cruz - avatar
2 Answers
+ 1
Your query is not clear from your code. Could you please explain more?
31st May 2020, 4:56 AM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
+ 1
I fixed it nvm
31st May 2020, 4:57 AM
Jeremy Cruz
Jeremy Cruz - avatar