![]() |
My very first "thing" what I'm somewhat proud of, after a week udomy class. Register - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: Code Review (https://python-forum.io/forum-46.html) +--- Thread: My very first "thing" what I'm somewhat proud of, after a week udomy class. Register (/thread-27669.html) |
My very first "thing" what I'm somewhat proud of, after a week udomy class. Register - Haulpa - Jun-16-2020 import time def log_in (): return () print("Register:") ui = [] pw = [] while True == 1: userid = input("Give you User name: " ) password = input("Give your password: ") if userid in ui: print('Userid already in use!') True == 1 else: print('You registered successfully!!') ui.insert(0, userid) pw.insert(0, password) #print (ui) #print (pw) #True == 1 break time.sleep(2) import os os.system('clear') while True == 1: print("Log In:") if input("User ID: ") in ui: if input("Password: ") in pw: print("Succesfull LogIn!") import webbrowser webbrowser.open('http://www.youtube.com', new=2) break True == 4 else: print("Wrong User name or password!! Try again!!") RE: My very first "thing" what I'm somewhat proud of, after a week udomy class. Register - snippsat - Jun-16-2020 (Jun-16-2020, 11:30 AM)Haulpa Wrote: My very first "thing" what I'm somewhat proud of, after a week udomy class. RegisterYes you should be proud of it ![]() A quick look fixing some stuff like all imports first and while True without == 1 is enough.Try to keep 4-space indentation in all code blocks. The logic is okay for one time run trough,but will never reach these lines. if userid in ui: print("Userid already in use!")Then need to save ui and pw to disk,which good be an improvement.Also a menu of that's tell what's logging into would help,then could also looking at using functions for this. Here is the clean up,not doing any extra stuff as mention over. import time import os import webbrowser ui = [] pw = [] print("Register:") while True: userid = input("Give you User name: ") password = input("Give your password: ") if userid in ui: print("Userid already in use!") else: print("You registered successfully!!") ui.insert(0, userid) pw.insert(0, password) break time.sleep(2) os.system("clear") while True: print("Log In:") if input("User ID: ") in ui: if input("Password: ") in pw: print("Succesfull LogIn!") webbrowser.open("http://www.youtube.com", new=2) break else: print("Wrong User name or password!! Try again!!") RE: My very first "thing" what I'm somewhat proud of, after a week udomy class. Register - Haulpa - Jun-16-2020 Thanka your advice! I know it is ok for 1 time run through this is why I left this lines: #print (ui) #print (pw) #True == 1 For repeat and see if I can save ui and pw in a list. I just wanted for now figure out how is all done and actually I have no idea yet how I can save them to disk ? but I will check. RE: My very first "thing" what I'm somewhat proud of, after a week udomy class. Register - Haulpa - Jun-19-2020 In line 17 and 19 what can i do for when i run first time it creat the file and it can read it but when i run it again dont over write it? Right now if i run it first time it says the file dosn`t exit because it read only, but if i change to write the first time it is runing ok but the secound time it cant read it. I hope i explaind it clear import time import os import webbrowser import smtplib, ssl port = 465 context = ssl.create_default_context() arroba = '@' point = '.' print("Register:") while True: userid = input("Give you User name: ") password = input("Give your password: ") email = input("Your email: ") emailfile = open('emailfile.txt', 'r') #email of "client" emailcontent = emailfile.read() userfile = open('userfile.txt', 'r') uicontent = userfile.read() if userid in uicontent: print("Userid already in use!") elif len(password) < 5: print('Too short password, minimum 5 character') elif arroba not in email: print('Not valid email!') elif point not in email: print('Not valid email') elif email in emailcontent: print('Email already in use!!') else: with open ('userfile.txt', "a+") as f: f.write (''.join (userid) + '\n'); with open ('passfile.txt', "a+") as f: f.write (''.join (password) + '\n') with open ('emailfile.txt', "a+") as f: f.write ("".join(email) + '\n') print("You registered successfully!!") ui.insert(0, userid) pw.insert(0, password) sender_email = "email_of the sender" #company email password = 'sender_email_password' #company email password receiver_email = email # Enter client address message = "You registered successfully" # sent massage with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server: server.login(sender_email, password) server.sendmail(sender_email, receiver_email, message) break time.sleep(2) os.system("cls") while True: uicheck = open ('userfile.txt', 'r') uicheck2 = uicheck.read() pwcheck = open('passfile.txt', 'r') pwcheck2 = pwcheck.read() print("Log In:") if input("User ID: ") in uicheck2: if input("Password: ") in pwcheck2: print("Succesfull LogIn!") webbrowser.open("http://www.youtube.com", new=2) break else: print("Wrong User name or password!! Try again!!") else: print("Wrong User name or password!! Try again!!") You have to delete line 39 and 40 bacause i left it inside... ui.insert(0, userid) pw.insert(0, password) |