Aug-05-2019, 01:39 PM
(This post was last modified: Aug-05-2019, 01:40 PM by hikerguy62.)
I took a look at that example but it wasn't making sense to me, so I found another snippet. I almost have it, but when I run the code below, it's giving me a syntax error and I don't know why:
C:\Users\tomel\Desktop>testing.py
File "C:\Users\tomel\Desktop\testing.py", line 14
else:
^
SyntaxError: invalid syntax
import os import shutil newdir = input("Enter name of directory: ") dir_exists = (os.path.exists("C:\\TIM\\SITES\\" + newdir)) newdir = ("C:\\TIM\\SITES\\" + newdir) support_files = ("C:\\TIM\\SITES\\FILES FOR CONFIG BUILD\\") while dir_exists: try: newdir = input("Enter name of directory: ") dir_exists = (os.path.exists("C:\\TIM\\SITES\\" + newdir)) else: os.mkdir(newdir)Here's what I see when I run it. I can't figure out what it doesn't like about the else statement:
C:\Users\tomel\Desktop>testing.py
File "C:\Users\tomel\Desktop\testing.py", line 14
else:
^
SyntaxError: invalid syntax