Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling from a file
#1
My goal: when a user enters a username it calls their password from a text document of multiple peoples passwords for password verification.

Info: Passwords when written are put on separate lines for ease of access. usernames are written to a separate text document.

My problem: So i'm new to python but have a decent understanding of the basics. all i want is for the user to be able to pull their password for verification as i intend to have multiple users able to access scores and difficulty of quizes they have taken, quiz score and info are also stored on a text document, now i know how to read certain lines of a text document BUT getting the program to define usernames to certain passwords is beyond me i currently have this setup to ask them if they do actually own an account ,the firstname(), is for if they dont as a username is a combination of the three first letters of their name and their age :

def usernameask():
global user
print("Do you allready have a username and password?")
user = input(str("Please answer in lower case: "))
askcheck()

def askcheck():
if user == str("yes"):
passverification()
else:
print("You must create a user account")
firstname()

if anyone could help me get their password but not tell them from here it would be greatly appreciated, thanks.
Reply
#2
Hello and welcome to the forums!
Users are requested to post their code in Python code tags, so your code is clear and easier to read to users who want to help you. You can read about it in the link and edit your post accordingly:
https://python-forum.io/misc.php?action=help&hid=25

That said, from the code you posted (ignoring a couple of other doubtful items), you need to implement "passverification()" function. You said passwords will be stored in a file, so you will have to tackle file IO functionality of Python. For basic tasks like yours, it is simple enough, you can start here:
https://www.programiz.com/python-program...-operation
You can also search our forums, since there were plenty of questions (and answers) regarding file IO. Of course, you will also need to decide upon username-password text file formatting. E.g.: lines of "username password", or "username, password", or "username - password" etc... This is up to you.
Feel free to let us know how it is going and post further code or questions you may come up with. =) Good luck!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a function (which accesses a library) from another file mouse9095 4 766 Jun-07-2023, 08:55 PM
Last Post: deanhystad
  Duplicate output when calling a custom function from the same file? road2knowledge 2 2,343 May-10-2019, 07:58 AM
Last Post: road2knowledge
  Calling functions from another file jp2017 11 30,404 Oct-11-2017, 10:58 PM
Last Post: snippsat
  Calling a C Func though Pyhon Script using DLL file which is created for C file. CMMouli 4 4,571 Feb-18-2017, 05:06 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020