I am experiencing an issue with nested if statements in Python running on repl.it and would like help determine what I am doing wrong or if there is a great way to rework the entire section.
Background and Current Goal: I am attempting to make a generic settings module that will work with various different programs. My goal for the problem block is to be able to detect when a variable is set to a specific string (by a string splitter) to identify the command, and then check the arguments (another variable). Finally, whatever the command does would be executed.
Issue Python/repl.it will not accept my nested if statements.
The problem block:
elif(Command=="debug"):
print("Not Fully Implemented")
if(Args=='-E'):
DebugMode =="Enabled"
elif(Args=="D-"):
DebugMode == "False"
elif(Args=="-query"):
print(str(DebugMode)
else:
print("Argument Error. For a valid list of commands, type 'help'")
The Error message (Ignore Color)
Python 3.6.1 (default, Dec 2015, 13:05:11)
[GCC 4.8.2] on linux
File "main.py", line 68
else:
^
SyntaxError: invalid syntax
The full program so far:
#SettingsCommandLineUitily #Imports #Initization print("Starting Settings Utitlies... 000%",end="\r") from time import sleep import sys
#Initizatin Countdown
INIT_PERCENT=0
for i in range(97):
print("Loading Settings Utitlies... " + str(INIT_PERCENT) + "%", end="\r")
INIT_PERCENT += 1
sleep(0.015)
#Defing Variables
global Args2
global Command
global Args
global DebugMode
DebugMode = "Enabled"
print("Loading Settings Utitlies... 97%", end="\r")
#String Artist
#Splits Input comands into command, args, and args 2 via a space
def StringArtist(CommandIn):
#Import globals
global Command
global Args
global Args2
#Parseing
ParsedCommand = CommandIn.split(" ")
ParsedCommand.append("Null")
ParsedCommand.append("Null")
Command = ParsedCommand[0]
Args = ParsedCommand[1]
Args2 = ParsedCommand[2]
print("Loading Settings Utitlies... 98%", end="\r")
#Command Parser
#Interpets Comands and Arguments
def CommandParser(Command, Args, Args2):
if(Command=="help"):
print("Displaying Help... ",end="\n")
print("Command Args Function",end="\n")
print("exit Exits the helps utilty.",end="\n")
print("help Displays This Help Dialogue",end="\n")
print("vol -[0-100/+/-/+10/-10/query] Sets the volume as a percenage where zero is off",end="\n")
print("graphics -[(B/N/W/query) Sets the graphics qualitiy (Best/Normal/Worst)]",end="\n")
print("_ Not Implemented",end="\n")
print("debug -[E/D/query] Not Implemented",end="\n")
elif(Command=="exit"):
print("Exiting to Program...")
sys.exit(000)
elif(Command=="vol"):
print("Not Implemented")
elif(Command=="graphics"):
print("Not Implemented")
elif(Command=="_"):
print("Not Implemented")
elif(Command=="debug"):
print("Not Fully Implemented")
if(Args=='-E'):
DebugMode =="Enabled"
elif(Args=="D-"):
DebugMode == "False"
elif(Args=="-query"):
print(str(DebugMode)
else:
print("Argument Error. For a valid list of commands, type 'help'")
elif(Command=="Null"):
sys.exit("Input may not have a value of 'Null'. Program Error Code #201")
elif(Command==""):
print("To exit settings and return to your program type exit")
else:
print("Command not reconized. To refer to a refernce list, type 'help'.")
print("Loading Settings Utitlies... 99%", end="\r")
def Main():
print("\nReturing to Settings Utily...")
#Import global variables
global Command
global Args
global Args2
#Main
print("Enter Command Below or type help for help.")
#CommandIn=input()
StringArtist(input())
CommandParser(Command, Args, Args2)
#command = "NUll"
#Args = "Null"
#Args2= "Null"
print("Loading Settings Utitlies... COMPLETE", end="\n")
#Debuger
if(DebugMode=="Enabled"):
while True:
Main()
Aucun commentaire:
Enregistrer un commentaire