lundi 20 avril 2020

Invalid syntax python 2.7

The else statement keeps flagging as invalid syntax, in the Visual Studio 2019 IDE and when running the .py file outside the IDE. I keep seeing invalid token for else: However looking through the python docs this appears to be correct. I am working on building out a system reboot script to push through a MDM solution. This is just the very basic start of the script.

import os
import time
import datetime

WorkStatus = input ("We are going to restart this computer now, did you save your work? Y or N")

if workStatus == n: print ('Save your work now restart will occur in 5 minutes')
    # wait 5 minutes
print ("rebooting in 5 minutes")
time.sleep(300)

else:
    os.system ("Shutdown /r /t 10")

Aucun commentaire:

Enregistrer un commentaire