Wow, that is too much effort .
Before help - 444 lines of code , and many of them redundant - you need Code Review first.
Let me start by - ever heard of lists, elif? You just don't add numbers to names - you make list!
Let's start
But still - you write a lot of redundant code - you first function - since only one condition will be true - all ifs, startig from second and excluding the last, should be elifs, and the last should be else
So, instead of this monstrosity, you may write just that
I am done for now. Now your turn - start chopping away redundancies in your code
Before help - 444 lines of code , and many of them redundant - you need Code Review first.
Let me start by - ever heard of lists, elif? You just don't add numbers to names - you make list!
Let's start
passwords = [""] * 6Now, about global - the only time you need global is when you want to re-assign value within a function - and it is still a bad idea. Outer-scope variables are visible within enclosed functions as they are - without qualifier. Still, arguments are better
But still - you write a lot of redundant code - you first function - since only one condition will be true - all ifs, startig from second and excluding the last, should be elifs, and the last should be else
if which_password == 0: ..... elif which_password == 1: .....But even that is still lousy! Why? You repeat yourself! And - as I was recently preached to on FB , there's a DRY approach (the priestess called it paradigm ), Don't Repeat Yourself
So, instead of this monstrosity, you may write just that
def check_userpass(password_index, password_guess, passwords): if password_index == 0: return password_guess == passwords[0] elif password_index <len(passwords): return MD5me(password_guess) == passwords[password_index] return FalseConcise, readable and to the point.
I am done for now. Now your turn - start chopping away redundancies in your code
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.