how do i create a username and password system that remembers different usernames everytime i use the code?










-1















i need to create a music quiz game but only authorised players are allowed to play the game so i figured id create a username and password system but how do i do this please?



so far i have this:



name = input("Please enter your name. ")
age = input("Now please enter you age. ")

username = name[0:3] + age
print ("Your username has been created and
is", username, ".")

password = input("Now please create a
password. ")

file = open("Login.txt","a")
file.write (username)
file.write (",")
file.write (password)
file.write("n")
file.close()

print ("Your login details have been saved")


it saves the username and passwords created but how do I create a system so that the user can just enter their username and password after this from the stored usernames and passwords?










share|improve this question




























    -1















    i need to create a music quiz game but only authorised players are allowed to play the game so i figured id create a username and password system but how do i do this please?



    so far i have this:



    name = input("Please enter your name. ")
    age = input("Now please enter you age. ")

    username = name[0:3] + age
    print ("Your username has been created and
    is", username, ".")

    password = input("Now please create a
    password. ")

    file = open("Login.txt","a")
    file.write (username)
    file.write (",")
    file.write (password)
    file.write("n")
    file.close()

    print ("Your login details have been saved")


    it saves the username and passwords created but how do I create a system so that the user can just enter their username and password after this from the stored usernames and passwords?










    share|improve this question


























      -1












      -1








      -1








      i need to create a music quiz game but only authorised players are allowed to play the game so i figured id create a username and password system but how do i do this please?



      so far i have this:



      name = input("Please enter your name. ")
      age = input("Now please enter you age. ")

      username = name[0:3] + age
      print ("Your username has been created and
      is", username, ".")

      password = input("Now please create a
      password. ")

      file = open("Login.txt","a")
      file.write (username)
      file.write (",")
      file.write (password)
      file.write("n")
      file.close()

      print ("Your login details have been saved")


      it saves the username and passwords created but how do I create a system so that the user can just enter their username and password after this from the stored usernames and passwords?










      share|improve this question
















      i need to create a music quiz game but only authorised players are allowed to play the game so i figured id create a username and password system but how do i do this please?



      so far i have this:



      name = input("Please enter your name. ")
      age = input("Now please enter you age. ")

      username = name[0:3] + age
      print ("Your username has been created and
      is", username, ".")

      password = input("Now please create a
      password. ")

      file = open("Login.txt","a")
      file.write (username)
      file.write (",")
      file.write (password)
      file.write("n")
      file.close()

      print ("Your login details have been saved")


      it saves the username and passwords created but how do I create a system so that the user can just enter their username and password after this from the stored usernames and passwords?







      python python-3.4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 12:58







      xxMagnum

















      asked Nov 13 '18 at 9:27









      xxMagnumxxMagnum

      116




      116






















          3 Answers
          3






          active

          oldest

          votes


















          0














          You can use dictionnary for doing it.



          import json

          create_user():
          global users
          name = input("Please enter your name. ")
          age = input("Now please enter you age. ")

          username = name[0:3] + age
          print ("Your username has been created and is", username, ".")

          password = input("Now please create a password.")
          users[username] = password
          with open ("Login.txt", 'w') as fd:
          json.dump(users, fd)
          print("Your login details have been saved")

          load_users():
          try:
          with open("Login.txt", 'r') as fd:
          users = json.load(fd)
          except:
          print("can't load Login.txt, default dict used")
          users =

          login():
          username = input("username >")
          password = input("password >")
          if username in users.keys() and password == users[username]:
          print("logged as", username)
          return username
          else
          print("login failed")
          return None
          users = load_users()





          share|improve this answer






























            0














            Some suggestions flat out:



            • Ask for the password twice at the time of creation; saves the pain of dealing with typos

            • Use getpass.getpass() for inputting passwords

            • Don't store passwords in a file. If databases are too much of a hassle, use one-way hash functions.

            Now, assuming you'd still like to continue without a database, an easier way to do this might be to store username-password pairs in a dictionary format in [say] a pickle object. Every time you ask somebody to log in, ask for a username, check for the presence of the username in the dictionary keys. If you find the key, ask for the password, and match it with the value corresponding to the key.



            from getpass import getpass
            import os, pickle, hashlib
            userdata = dict()
            if os.path.exists('userinfo.pickle'):
            userdata = pickle.load(open('userinfo.pickle','rb'))
            username = raw_input("Enter username:")
            pwd = getpass("Enter password:")
            pwd2 = getpass("Enter password again:")
            if pwd != pwd2:
            exit(0)
            h = hashlib.md5()
            h.update(pwd)
            pwd = h.hexdigest()
            if username not in userdata:
            userdata[username] = pwd
            with open('userinfo.pickle','wb') as handle:
            pickle.dump(userdata,handle)

            # Logging in
            userdata = pickle.load(open('userinfo.pickle','rb'))
            username = raw_input("Enter username:")
            pwd = getpass("Enter password:")
            h = hashlib.md5()
            h.update(pwd)
            pwd = h.hexdigest()
            if username in userdata:
            if userdata[username] == pwd:
            print("Success.")
            else:
            print("Incorrect password.")
            else:
            print("User not found.")


            This should do it.






            share|improve this answer






























              0














              I think you would be better off using a CSV to separate your names and usernames, this would make it much easier to search for a username and password pair. If you would want to use this, the following should work:



              Creating username/password:



              import pandas as pd

              userpass = pd.read_csv('Login.csv')
              name = input("Please enter your name. ")
              age = input("Now please enter you age. ")

              username = name[0:3] + age
              print ("Your username has been created and
              is", username, ".")

              password = input("Now please create a
              password. ")

              newuserpass = [(username, password)]
              newuserpass = pd.DataFrame(newuserpass) #Creates a dataframe of username & pass
              userpass = userpass.append(newuserpass) #Adds username and pass dataframe to end of username/password save file
              userpass.to_csv('Login.csv')
              '''This has now saved the login details. Now to read the login details, where pandas makes this quite easy'''


              Loading username/password:



              loggedin = 0
              while loggedin = 0:
              userpass = pd.read_csv('Login.csv')
              inputusername = input('What is your username?')
              inputpassword = input('What is your password?')




              if userpass.Password.values[userpass.Username==inputusername] == inputpassword:
              userpass = 1
              print('Logged in successfully!')


              You will need to create a blank file named 'Login.csv' with Username, Password as its contents before this code would function.






              share|improve this answer























              • thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                – xxMagnum
                Nov 14 '18 at 12:53











              • Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                – Fishbones78
                Nov 14 '18 at 15:28











              • i cant install it! im doing this in school :(

                – xxMagnum
                Nov 15 '18 at 14:04











              • Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                – Fishbones78
                Nov 15 '18 at 16:13










              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277743%2fhow-do-i-create-a-username-and-password-system-that-remembers-different-username%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              You can use dictionnary for doing it.



              import json

              create_user():
              global users
              name = input("Please enter your name. ")
              age = input("Now please enter you age. ")

              username = name[0:3] + age
              print ("Your username has been created and is", username, ".")

              password = input("Now please create a password.")
              users[username] = password
              with open ("Login.txt", 'w') as fd:
              json.dump(users, fd)
              print("Your login details have been saved")

              load_users():
              try:
              with open("Login.txt", 'r') as fd:
              users = json.load(fd)
              except:
              print("can't load Login.txt, default dict used")
              users =

              login():
              username = input("username >")
              password = input("password >")
              if username in users.keys() and password == users[username]:
              print("logged as", username)
              return username
              else
              print("login failed")
              return None
              users = load_users()





              share|improve this answer



























                0














                You can use dictionnary for doing it.



                import json

                create_user():
                global users
                name = input("Please enter your name. ")
                age = input("Now please enter you age. ")

                username = name[0:3] + age
                print ("Your username has been created and is", username, ".")

                password = input("Now please create a password.")
                users[username] = password
                with open ("Login.txt", 'w') as fd:
                json.dump(users, fd)
                print("Your login details have been saved")

                load_users():
                try:
                with open("Login.txt", 'r') as fd:
                users = json.load(fd)
                except:
                print("can't load Login.txt, default dict used")
                users =

                login():
                username = input("username >")
                password = input("password >")
                if username in users.keys() and password == users[username]:
                print("logged as", username)
                return username
                else
                print("login failed")
                return None
                users = load_users()





                share|improve this answer

























                  0












                  0








                  0







                  You can use dictionnary for doing it.



                  import json

                  create_user():
                  global users
                  name = input("Please enter your name. ")
                  age = input("Now please enter you age. ")

                  username = name[0:3] + age
                  print ("Your username has been created and is", username, ".")

                  password = input("Now please create a password.")
                  users[username] = password
                  with open ("Login.txt", 'w') as fd:
                  json.dump(users, fd)
                  print("Your login details have been saved")

                  load_users():
                  try:
                  with open("Login.txt", 'r') as fd:
                  users = json.load(fd)
                  except:
                  print("can't load Login.txt, default dict used")
                  users =

                  login():
                  username = input("username >")
                  password = input("password >")
                  if username in users.keys() and password == users[username]:
                  print("logged as", username)
                  return username
                  else
                  print("login failed")
                  return None
                  users = load_users()





                  share|improve this answer













                  You can use dictionnary for doing it.



                  import json

                  create_user():
                  global users
                  name = input("Please enter your name. ")
                  age = input("Now please enter you age. ")

                  username = name[0:3] + age
                  print ("Your username has been created and is", username, ".")

                  password = input("Now please create a password.")
                  users[username] = password
                  with open ("Login.txt", 'w') as fd:
                  json.dump(users, fd)
                  print("Your login details have been saved")

                  load_users():
                  try:
                  with open("Login.txt", 'r') as fd:
                  users = json.load(fd)
                  except:
                  print("can't load Login.txt, default dict used")
                  users =

                  login():
                  username = input("username >")
                  password = input("password >")
                  if username in users.keys() and password == users[username]:
                  print("logged as", username)
                  return username
                  else
                  print("login failed")
                  return None
                  users = load_users()






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 9:50









                  iEldeniElden

                  642317




                  642317























                      0














                      Some suggestions flat out:



                      • Ask for the password twice at the time of creation; saves the pain of dealing with typos

                      • Use getpass.getpass() for inputting passwords

                      • Don't store passwords in a file. If databases are too much of a hassle, use one-way hash functions.

                      Now, assuming you'd still like to continue without a database, an easier way to do this might be to store username-password pairs in a dictionary format in [say] a pickle object. Every time you ask somebody to log in, ask for a username, check for the presence of the username in the dictionary keys. If you find the key, ask for the password, and match it with the value corresponding to the key.



                      from getpass import getpass
                      import os, pickle, hashlib
                      userdata = dict()
                      if os.path.exists('userinfo.pickle'):
                      userdata = pickle.load(open('userinfo.pickle','rb'))
                      username = raw_input("Enter username:")
                      pwd = getpass("Enter password:")
                      pwd2 = getpass("Enter password again:")
                      if pwd != pwd2:
                      exit(0)
                      h = hashlib.md5()
                      h.update(pwd)
                      pwd = h.hexdigest()
                      if username not in userdata:
                      userdata[username] = pwd
                      with open('userinfo.pickle','wb') as handle:
                      pickle.dump(userdata,handle)

                      # Logging in
                      userdata = pickle.load(open('userinfo.pickle','rb'))
                      username = raw_input("Enter username:")
                      pwd = getpass("Enter password:")
                      h = hashlib.md5()
                      h.update(pwd)
                      pwd = h.hexdigest()
                      if username in userdata:
                      if userdata[username] == pwd:
                      print("Success.")
                      else:
                      print("Incorrect password.")
                      else:
                      print("User not found.")


                      This should do it.






                      share|improve this answer



























                        0














                        Some suggestions flat out:



                        • Ask for the password twice at the time of creation; saves the pain of dealing with typos

                        • Use getpass.getpass() for inputting passwords

                        • Don't store passwords in a file. If databases are too much of a hassle, use one-way hash functions.

                        Now, assuming you'd still like to continue without a database, an easier way to do this might be to store username-password pairs in a dictionary format in [say] a pickle object. Every time you ask somebody to log in, ask for a username, check for the presence of the username in the dictionary keys. If you find the key, ask for the password, and match it with the value corresponding to the key.



                        from getpass import getpass
                        import os, pickle, hashlib
                        userdata = dict()
                        if os.path.exists('userinfo.pickle'):
                        userdata = pickle.load(open('userinfo.pickle','rb'))
                        username = raw_input("Enter username:")
                        pwd = getpass("Enter password:")
                        pwd2 = getpass("Enter password again:")
                        if pwd != pwd2:
                        exit(0)
                        h = hashlib.md5()
                        h.update(pwd)
                        pwd = h.hexdigest()
                        if username not in userdata:
                        userdata[username] = pwd
                        with open('userinfo.pickle','wb') as handle:
                        pickle.dump(userdata,handle)

                        # Logging in
                        userdata = pickle.load(open('userinfo.pickle','rb'))
                        username = raw_input("Enter username:")
                        pwd = getpass("Enter password:")
                        h = hashlib.md5()
                        h.update(pwd)
                        pwd = h.hexdigest()
                        if username in userdata:
                        if userdata[username] == pwd:
                        print("Success.")
                        else:
                        print("Incorrect password.")
                        else:
                        print("User not found.")


                        This should do it.






                        share|improve this answer

























                          0












                          0








                          0







                          Some suggestions flat out:



                          • Ask for the password twice at the time of creation; saves the pain of dealing with typos

                          • Use getpass.getpass() for inputting passwords

                          • Don't store passwords in a file. If databases are too much of a hassle, use one-way hash functions.

                          Now, assuming you'd still like to continue without a database, an easier way to do this might be to store username-password pairs in a dictionary format in [say] a pickle object. Every time you ask somebody to log in, ask for a username, check for the presence of the username in the dictionary keys. If you find the key, ask for the password, and match it with the value corresponding to the key.



                          from getpass import getpass
                          import os, pickle, hashlib
                          userdata = dict()
                          if os.path.exists('userinfo.pickle'):
                          userdata = pickle.load(open('userinfo.pickle','rb'))
                          username = raw_input("Enter username:")
                          pwd = getpass("Enter password:")
                          pwd2 = getpass("Enter password again:")
                          if pwd != pwd2:
                          exit(0)
                          h = hashlib.md5()
                          h.update(pwd)
                          pwd = h.hexdigest()
                          if username not in userdata:
                          userdata[username] = pwd
                          with open('userinfo.pickle','wb') as handle:
                          pickle.dump(userdata,handle)

                          # Logging in
                          userdata = pickle.load(open('userinfo.pickle','rb'))
                          username = raw_input("Enter username:")
                          pwd = getpass("Enter password:")
                          h = hashlib.md5()
                          h.update(pwd)
                          pwd = h.hexdigest()
                          if username in userdata:
                          if userdata[username] == pwd:
                          print("Success.")
                          else:
                          print("Incorrect password.")
                          else:
                          print("User not found.")


                          This should do it.






                          share|improve this answer













                          Some suggestions flat out:



                          • Ask for the password twice at the time of creation; saves the pain of dealing with typos

                          • Use getpass.getpass() for inputting passwords

                          • Don't store passwords in a file. If databases are too much of a hassle, use one-way hash functions.

                          Now, assuming you'd still like to continue without a database, an easier way to do this might be to store username-password pairs in a dictionary format in [say] a pickle object. Every time you ask somebody to log in, ask for a username, check for the presence of the username in the dictionary keys. If you find the key, ask for the password, and match it with the value corresponding to the key.



                          from getpass import getpass
                          import os, pickle, hashlib
                          userdata = dict()
                          if os.path.exists('userinfo.pickle'):
                          userdata = pickle.load(open('userinfo.pickle','rb'))
                          username = raw_input("Enter username:")
                          pwd = getpass("Enter password:")
                          pwd2 = getpass("Enter password again:")
                          if pwd != pwd2:
                          exit(0)
                          h = hashlib.md5()
                          h.update(pwd)
                          pwd = h.hexdigest()
                          if username not in userdata:
                          userdata[username] = pwd
                          with open('userinfo.pickle','wb') as handle:
                          pickle.dump(userdata,handle)

                          # Logging in
                          userdata = pickle.load(open('userinfo.pickle','rb'))
                          username = raw_input("Enter username:")
                          pwd = getpass("Enter password:")
                          h = hashlib.md5()
                          h.update(pwd)
                          pwd = h.hexdigest()
                          if username in userdata:
                          if userdata[username] == pwd:
                          print("Success.")
                          else:
                          print("Incorrect password.")
                          else:
                          print("User not found.")


                          This should do it.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 13 '18 at 9:55









                          Prateek DewanPrateek Dewan

                          2401215




                          2401215





















                              0














                              I think you would be better off using a CSV to separate your names and usernames, this would make it much easier to search for a username and password pair. If you would want to use this, the following should work:



                              Creating username/password:



                              import pandas as pd

                              userpass = pd.read_csv('Login.csv')
                              name = input("Please enter your name. ")
                              age = input("Now please enter you age. ")

                              username = name[0:3] + age
                              print ("Your username has been created and
                              is", username, ".")

                              password = input("Now please create a
                              password. ")

                              newuserpass = [(username, password)]
                              newuserpass = pd.DataFrame(newuserpass) #Creates a dataframe of username & pass
                              userpass = userpass.append(newuserpass) #Adds username and pass dataframe to end of username/password save file
                              userpass.to_csv('Login.csv')
                              '''This has now saved the login details. Now to read the login details, where pandas makes this quite easy'''


                              Loading username/password:



                              loggedin = 0
                              while loggedin = 0:
                              userpass = pd.read_csv('Login.csv')
                              inputusername = input('What is your username?')
                              inputpassword = input('What is your password?')




                              if userpass.Password.values[userpass.Username==inputusername] == inputpassword:
                              userpass = 1
                              print('Logged in successfully!')


                              You will need to create a blank file named 'Login.csv' with Username, Password as its contents before this code would function.






                              share|improve this answer























                              • thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                                – xxMagnum
                                Nov 14 '18 at 12:53











                              • Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                                – Fishbones78
                                Nov 14 '18 at 15:28











                              • i cant install it! im doing this in school :(

                                – xxMagnum
                                Nov 15 '18 at 14:04











                              • Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                                – Fishbones78
                                Nov 15 '18 at 16:13















                              0














                              I think you would be better off using a CSV to separate your names and usernames, this would make it much easier to search for a username and password pair. If you would want to use this, the following should work:



                              Creating username/password:



                              import pandas as pd

                              userpass = pd.read_csv('Login.csv')
                              name = input("Please enter your name. ")
                              age = input("Now please enter you age. ")

                              username = name[0:3] + age
                              print ("Your username has been created and
                              is", username, ".")

                              password = input("Now please create a
                              password. ")

                              newuserpass = [(username, password)]
                              newuserpass = pd.DataFrame(newuserpass) #Creates a dataframe of username & pass
                              userpass = userpass.append(newuserpass) #Adds username and pass dataframe to end of username/password save file
                              userpass.to_csv('Login.csv')
                              '''This has now saved the login details. Now to read the login details, where pandas makes this quite easy'''


                              Loading username/password:



                              loggedin = 0
                              while loggedin = 0:
                              userpass = pd.read_csv('Login.csv')
                              inputusername = input('What is your username?')
                              inputpassword = input('What is your password?')




                              if userpass.Password.values[userpass.Username==inputusername] == inputpassword:
                              userpass = 1
                              print('Logged in successfully!')


                              You will need to create a blank file named 'Login.csv' with Username, Password as its contents before this code would function.






                              share|improve this answer























                              • thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                                – xxMagnum
                                Nov 14 '18 at 12:53











                              • Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                                – Fishbones78
                                Nov 14 '18 at 15:28











                              • i cant install it! im doing this in school :(

                                – xxMagnum
                                Nov 15 '18 at 14:04











                              • Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                                – Fishbones78
                                Nov 15 '18 at 16:13













                              0












                              0








                              0







                              I think you would be better off using a CSV to separate your names and usernames, this would make it much easier to search for a username and password pair. If you would want to use this, the following should work:



                              Creating username/password:



                              import pandas as pd

                              userpass = pd.read_csv('Login.csv')
                              name = input("Please enter your name. ")
                              age = input("Now please enter you age. ")

                              username = name[0:3] + age
                              print ("Your username has been created and
                              is", username, ".")

                              password = input("Now please create a
                              password. ")

                              newuserpass = [(username, password)]
                              newuserpass = pd.DataFrame(newuserpass) #Creates a dataframe of username & pass
                              userpass = userpass.append(newuserpass) #Adds username and pass dataframe to end of username/password save file
                              userpass.to_csv('Login.csv')
                              '''This has now saved the login details. Now to read the login details, where pandas makes this quite easy'''


                              Loading username/password:



                              loggedin = 0
                              while loggedin = 0:
                              userpass = pd.read_csv('Login.csv')
                              inputusername = input('What is your username?')
                              inputpassword = input('What is your password?')




                              if userpass.Password.values[userpass.Username==inputusername] == inputpassword:
                              userpass = 1
                              print('Logged in successfully!')


                              You will need to create a blank file named 'Login.csv' with Username, Password as its contents before this code would function.






                              share|improve this answer













                              I think you would be better off using a CSV to separate your names and usernames, this would make it much easier to search for a username and password pair. If you would want to use this, the following should work:



                              Creating username/password:



                              import pandas as pd

                              userpass = pd.read_csv('Login.csv')
                              name = input("Please enter your name. ")
                              age = input("Now please enter you age. ")

                              username = name[0:3] + age
                              print ("Your username has been created and
                              is", username, ".")

                              password = input("Now please create a
                              password. ")

                              newuserpass = [(username, password)]
                              newuserpass = pd.DataFrame(newuserpass) #Creates a dataframe of username & pass
                              userpass = userpass.append(newuserpass) #Adds username and pass dataframe to end of username/password save file
                              userpass.to_csv('Login.csv')
                              '''This has now saved the login details. Now to read the login details, where pandas makes this quite easy'''


                              Loading username/password:



                              loggedin = 0
                              while loggedin = 0:
                              userpass = pd.read_csv('Login.csv')
                              inputusername = input('What is your username?')
                              inputpassword = input('What is your password?')




                              if userpass.Password.values[userpass.Username==inputusername] == inputpassword:
                              userpass = 1
                              print('Logged in successfully!')


                              You will need to create a blank file named 'Login.csv' with Username, Password as its contents before this code would function.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 13 '18 at 10:04









                              Fishbones78Fishbones78

                              54




                              54












                              • thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                                – xxMagnum
                                Nov 14 '18 at 12:53











                              • Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                                – Fishbones78
                                Nov 14 '18 at 15:28











                              • i cant install it! im doing this in school :(

                                – xxMagnum
                                Nov 15 '18 at 14:04











                              • Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                                – Fishbones78
                                Nov 15 '18 at 16:13

















                              • thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                                – xxMagnum
                                Nov 14 '18 at 12:53











                              • Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                                – Fishbones78
                                Nov 14 '18 at 15:28











                              • i cant install it! im doing this in school :(

                                – xxMagnum
                                Nov 15 '18 at 14:04











                              • Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                                – Fishbones78
                                Nov 15 '18 at 16:13
















                              thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                              – xxMagnum
                              Nov 14 '18 at 12:53





                              thanks for the reply but it says 'no module names pandas'. help. ive created the blank file btw

                              – xxMagnum
                              Nov 14 '18 at 12:53













                              Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                              – Fishbones78
                              Nov 14 '18 at 15:28





                              Ah. You don't have Pandas installed. No worries, take a look at this link to get it. Pandas is a very useful library for data handling. pandas.pydata.org/pandas-docs/stable/install.html

                              – Fishbones78
                              Nov 14 '18 at 15:28













                              i cant install it! im doing this in school :(

                              – xxMagnum
                              Nov 15 '18 at 14:04





                              i cant install it! im doing this in school :(

                              – xxMagnum
                              Nov 15 '18 at 14:04













                              Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                              – Fishbones78
                              Nov 15 '18 at 16:13





                              Ah. That is a shame. This answer requires pandas - I'm surprised that your school doesn't have it. You will need to check if you can use 'import' to import any of the libraries in the other answers here. Best of luck.

                              – Fishbones78
                              Nov 15 '18 at 16:13

















                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277743%2fhow-do-i-create-a-username-and-password-system-that-remembers-different-username%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Barbados

                              How to read a connectionString WITH PROVIDER in .NET Core?

                              Node.js Script on GitHub Pages or Amazon S3