Python Forum

Full Version: First Try Skynet... How Can I improve?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys, so this is my first try doing my own Code. So how do you think? How can I improve my System? Any help will be appreciate. Please ignore my English as I am not a native English speaker.

print (" Welcome to The Skynet ")
identification = input (" Enter Your Identification ")
password = input (" Enter Your Password ")
if password == ("aaabbb"):
    print (" Verifying ID...")
else:
    print (" Access Denied.")
    print (" Intruder Alert")
    print (" GPS Scanning for Location")
    print (" Location Found")
    print (" Activate Theta Protocol")
    print ("Theta Protocol Activated")
    print ("Self Destruct Activated")
    print ("10 Seconds")
    quit()
print (" Verifying ID... ")
print ((" Verifying Completed. Welcome ") + identification)
CONTINUE = input ("Do You Want to Continue? ")
if CONTINUE == ("YES"):
    print ("   X Menu X   ")
    print (" 1. Nuclear Launch")
    print (" 2. Diplomatic")
    print (" 3. Blacklist")
    print (" 4. Log Out")
    action = input (" Please Choose The Option From The Following Menu ")
    if action == ("1"):
        CONFIRM = input (" Are Sure You Want to Launch The Nuclear? ")
        if CONFIRM == (" YES "):
            C1 = input (" To CONFIRM, Type NUCLEAR_WAR ")
            print ("Nuclear Launch Has Been Activated")
            print ("Countdown Begin in 30 Minutes")
        else:
            print (("Nuclear Launch Cancel. Thank You ") + identification)
            quit()
    if action == ("2"):
        print ("Choose the Country")
        print ("A. Russia")
        print ("B. China")
        print ("C. Malaysia")
        print ("D. Thailand")
        A1 = input (" Choose The Country ")
        if A1 == ("A"):
            print (" Peace Treaty Negotiation has been sent to Russia.")
            print ((" The World will be A Better World Thanks to You ") + identification)
        if A1 == ("B"):
            print (" A Delegation has been Sent to China.")
            print ((" May we Preserve the Future together. Thank You ") + identification)
        if A1 == ("C"):
            print (" Our Head of Secretary has been sent to Malaysia to strengthen our Partnership")
            print (" Malaysia is A Great Country, Our Partnership with Them Will bring a brighter Future")
            print ((" Thank You ") + identification)
        if A1 == ("D"):
            print (" Invitation has been sent to Thailand Ruler to discuss our Deal")
            print ((" Thank You ") + identification)
    if action == ("3"):
        print ("   MOST WANTED LIST   ")
        print (" a. 1 Fifa ")
        print (" b. 2 Star Wars ")
        print (" c. 3 Battlefield ")
        A2 = input ((" The End. Thank You ") + identification)
        quit ()
    if action == ("4"):
        print ((" Thank You ") + identification)
        
else:
    print ((" Thank You ") + identification)
Check out the functions and text adventures tutorials linked to from my signature below. Also, learn to love triple quoted strings:

text = """
It turns out
that strings
can have more than one line in them
without even
using backslash n
"""
print(text)
You call a quit() function several times, but that function isn't defined anywhere.
quit() is defined in the interpreter, it raises a SystemExit exception. It shouldn't be used in production code, though.
The Reason why I put quit is because I want my system to exit if we put the input. And as I research quit() is the only option to force it quit

The Reason why I put quit is because I want my system to exit if we put the input. And as I research quit() is the only option to force it quit
It's AN option, not the only option.  And, in my opinion, it's the worst option.  A better option would be to wrap all your code in a function, and then call it.  When you want to quit, just return instead.
def main():
    while True:
        keep_going = input("Keep going? ")
        if keep_going.lower() not in ("y", "yes", "1", "true"):
            return

if __name__ == "__main__":
    main()