Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

are you dumb python program

user_list = {}  # Imports an empty dictionary.
messages = {}
print("Welcome, admin. Please select a password:")
admin_password = input()
print('









































')

while 1 == 1:   # Creates a recursive loop. Probably a better way to do this.

    print(  #Greeting message.
        "
"
        "Press 1 to create a new account."
        "
Press 2 for a current list of users. (Only usable by admin)"
        "
Press 3 to send and receive messages."
        "
Press 4 for help."
        "
Please enter your choice:
"
        )

    user_input = input()    # Dictates which menu option to execute.

    if user_input == '1':
        print("
Please enter your preferred name:")
        attempted_name = input().lower()    # Disregards case.
        if attempted_name in user_list:     # Checks if name exists
            print("That name is already taken. Please choose again.")
        else:   # If name is unique, adds it to database.
            user_list.update({attempted_name.lower(): 'password'}) # Default password is "password" temporarily.
            print("Welcome to the site, "
                  + attempted_name +
                  "! Please choose a password:"
                  )
            user_list[attempted_name] = input()     # User defines new password.
            messages[attempted_name] = "DEFAULT MESSAGE"

    elif user_input == '2':     # Displays all current users and their passwords.
        print("Please enter admin password:")
        if input() == admin_password:
            print('
' + str(user_list))
        else:
            print('
Password incorrect. Please try again.')

    elif user_input == '3':     # messaging other users, checking messages
        login_name = input("Please enter your user name: ").lower()     # User login
        if login_name in user_list:
            login_password = input("Please enter password for " + login_name + ": ")
            if login_password == user_list[login_name]:
                print("
Correct password entered.
Press 1 to write a message.
Press 2 to read your message.
")
                user_option = input()
                if user_option == '1':
                    messaged_user = input("Please enter the name of the person you'd like to message:").lower()
                    if messages[messaged_user] != "DEFAULT MESSAGE":    # If user's message is "Default message", inbox
                        print("User's inbox is full.")                  #   is marked as full
                    else:
                        message = input("Please type your message:")
                        messages[messaged_user] = message
                elif user_option == '2':
                    print('
' + messages[login_name])
                    mark_read = input("Mark message as read? y/n:")
                    if mark_read == "y":
                        print ("
Message marked as 'read'.")
                        messages[login_name] = "DEFAULT MESSAGE"    # If user marks message as read, it returns to
                    elif mark_read == "n":                          #   default, which opens up the inbox for more
                        print ("
Message not marked as 'read'.")   #   messages.
                    else:
                        print("
Invalid option.")
                else:
                    print("
 That is not a valid option.")
            else:
                print("
Password not valid.")
        else:
            print("
Invalid username.")


    else:   # Help message.
        print(
            "This is a simple messaging database. "
            "When creating a username,
it must be unique, "
            "but the system will automatically
format your unique "
            "username to be in all lowercase.
"
            "Passwords, however, are case-sensitive."
            "Messages can be sent to other users, and users "
            "can check their own messages."
            )
# done
Comment

PREVIOUS NEXT
Code Example
Python :: Basic 13 Algorithm 
Python :: Matplotlib scatter plot custom point annotation 
Python :: send notification from pc to phone using python 
Python :: Drop multiple consecutive columns 
Python :: Select non-NaN rows and replace column value 
Python :: python matrices access row 
Python :: How to draw a Ninja Design using python turtle 
Python :: python google translator 
Python :: empty show non python 
Python :: python kdtree import 
Python :: how to return value in new record to odoo 
Python :: hover 777-286 
Python :: change the surface color rhinopython 
Python :: Subtract layers 
Python :: picobot python 
Python :: python selenium canvas fingerprinting 
Python :: part of list into dataframe 
Python :: def areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight):python execution 
Python :: topaz barziv 
Python :: micropython string to int 
Python :: [E053] Could not read config.cfg from C:UsershpAppDataLocalProgramsPythonPython37libsite-packages esume_parserdegreemodelconfig.cfg 
Python :: Return a new RDD containing the distinct elements in this RDD. 
Python :: Gets an existing SparkSession or, if there is no existing one, creates a new one based on the options set in this builder 
Python :: python triée plusieurs fois avec virgule 
Python :: oscillating fan 
Python :: python library automatic sort 
Python :: how to i print oin pyhton 
Python :: group your data columns by their data types 
Python :: tf.slice 
Python :: how to delete a cell in jupyter notebook 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =