I am building a storage script. So far, the computer will ask me for a username and password, and if they are incorrect, the program will shut down. But if the username and password are correct, it will ask the person if they want to open what's in their storage, add to the file, or log out.
Here's my script so far:
username = "storagei"
password = "something"
# asking for a username and password.
userInput = input("welcome back to safespace! Please type in your username to access your data.\n")
if userInput == username:
userInput = input("Password?\n")
if userInput == password:
print("Welcome back to safespace Izzy!")
else:
print("That is the wrong password. Please try again.")
else:
print("There is no username that matches what your responce. Please try again.")
print "You can open_storage, add_to_storage, or log_out"
userInput = input("What would you like to do?\n")
log_out = "Thanks for using safespace. Come back soon!"
open_storage = "opening files."
add_to_storage = "what do you like to add?"
if userInput == log_out:
print("Thanks for using safespace. Come back soon!")
Here's my problem though. If someone gets the username or password wrong, it won't stop the script like I want it to. Instead, it will ask the person this:
print "You can open_storage, add_to_storage, or log_out"
userInput = input("What would you like to do?\n")
log_out = "Thanks for using safespace. Come back soon!"
open_storage = "opening files."
add_to_storage = "what do you like to add?"
if userInput == log_out:
print("Thanks for using safespace. Come back soon!")
And that part is only supposed to show up if the person gets the username and password right.
I've tried adding the part right after it welcomes you to the site, but it kept putting up the error message.
So what I need to find out is either how to stop the script if someone get the username or password wrong, it will shut the program down. Or where to move the bottom part so it won't ask you anymore questions if you get the username or password wrong.
If you know how to solve my problem, I would love to hear it.