10 AnswersNew Answer
oop is about making objects so you could start with deciding what classes you are going to make and for what purpose they will be made for.
You'd need to go through the filehandling section here, but its fairly simple. The hard part is writing the data so its easy to read. Cause you'd have to code that too
Thanks, in this scenario my class would be just be User. class User(): def __init__(self, username, password, email): self.username = username self.password = password self.email = email def login(self, username, password): self.username = input("Enter username: ") self.password = input("Enter password: ") with open("register.txt", "r", encoding=utf-8) as file: if username == username and password == password: print("login successful!") Would this be sufficient?
Not really, cause it seems like you want to keep a database text file of usernames and passwords. But your code opens up a file to read it and does nothing with it. Then it compares 2 strings against themselves so it will ALWAYS print out "login successful"
How would i give an error if either does not match with the name and passwords stored in a file?
How would i save the details to a new file?
I've gone through the sections and whilst i understand it, when it comes to writing the code i seem to get stuck. This had been the case for every aspect of my project as well.
trial and error is your friend! Also try writing out some code and then bring that to us
Hi guys, i manged to create a screen and connect to sqlite3 db but when i run the code the text is not visble in the gui screen and typerror. missing 1 required positional argumemt. any advise? i didn't include an __init__ method, could this be the issue?
it's very possible you didn't include the "self" parameter in your __init__ definition