Hi guys looking for a little help, had been using code academy previously and learned alot, doing it myself im having some issues with my program.
I am using pycharm and my pc has the latest python download installed, testing my program on ide works fine. In browser IDES it works fine, but when i run it on the console it crashes at a specific part, i cant figure out why.
My program is basic username and password creation program, though it would be good to move it into OOP when moving forward.
When you make your password if incorrect it responds correctly and tells you to try again, however when you enter the right combo it just crashes out saving none of the progress.
I think the error is around line 137 however no errors when compiling. There are some adjustments im going to make to it as well but id like to get it working on both. It was only showing a friend my program that i noticed it does not work in console.
hi there thanks for the reply. Yeah i know my position check wont work if the password matches another user. Gonna fix that later on doing it within the same list.
the one u said i knew about so thats cool , i have a fix im working on for it. Thank you for the info on cls, just though it would make the output nicer, weird tho cause that is something that works in console and not ide lol
Although i have Windows installed, i have nothing setup there (no python, nothing). So that would take me ages.
Lets see if any exceptions occur:
def CreatePass():
try:
valid_password = False
while not valid_password:
valid_password = True
# to reset at the start of each loop
print("**Barraclough Systems****")
print("\nYou password must contain :")
print("1 Upper Case Character")
print("1 Lower Case Character")
print("1 Number")
print("1 Special Symbol from the following ! £ $ % & @ # ? ")
print("Must be between 8 - 16 characters in length\n")
print("")
Symbols = ["!", "£", "$", "%", "&", "@", "#","?"]
# creation of symbols to allow checking
password = input("Enter a password = ")
# password will then go through validation checks
if len(password) < 8 or len(password) > 16:
print ("\npassword needs to be between 8 and 16 characters")
valid_password = False
if not any(char.isupper() for char in password):
print ("\nPassword needs an upper case character.")
valid_password = False
if not any(char.islower() for char in password):
print ("\nPassword requires a lower case character.")
valid_password = False
if not any(char.isdigit() for char in password):
print ("\nPassword requires a number.")
valid_password = False
if not any(char in Symbols for char in password):
print ("\nPassword requires a special character (! £ $ % & @ # ? ). Please try again\n ")
valid_password = False
# If valid the password will be added to the list
if valid_password:
passwords.append(password)
#open the file to save the data 2
pck_file = open("data.pck", "wb")
pickle.dump(usernames, pck_file)
pickle.dump(passwords, pck_file)
pck_file.close()
#close the file
print("\nYour Password Has been Accepted\n")
print("You will now be redirected to the menu where you can log in")
time.sleep(4)
os.system("cls")
else:
print('\n\nPlease try again\n\n')
except:
print(sys.exc_info()[0])
don’t forgot to import sys. Does this given any output? Try/except allow us to handle exceptions (that is the only thing i added)
if it doesn’t work, you can always comment out everything after this line:
password = input("Enter a password = ")
print('get here')
# comment out the rest of functions
then slowly start uncommenting until you found the line it crashed.
reference words like it can be confusing. What do you mean by it? Have you verified what you expect matches reality?
that is a possibility, good thing to check. the os module (which you already imported) allows to see which files are in the directory. Maybe try this? Your thinking process is heading in the right direction
sorry i just meant that the file itself, when i set the program to save the file that it would go to the same directory as the .py file i had been using.
using the os module ? something like path ?, im not overly sure how to use those all.
Something like import os.path path.isfile('data.pck')
Well yeah. I use pycharm to click go to directory and i right click the .py file and run in python from there so i dont see how it could be another directory.
You can do that another time, first add getcwd() (see reply previous link) to your program just before you try to open file, then run your program with the command line and the IDE. See if the working directory is the same in both cases.