Jun-21-2017, 01:03 AM
Oh, first of all, pass is a statement and can not be used as a variable name.
You should first learn the language. There are many good tutorials.
Additional you should play inside the python repl to understand the code better.
Do small steps.
The code example is really bad. Here with different variable names.
You should first learn the language. There are many good tutorials.
Additional you should play inside the python repl to understand the code better.
Do small steps.
The code example is really bad. Here with different variable names.
username_password_list = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] user_you_seek = 'yahoo' for username, password in username_password_list: # simple unpacking of the two elements to username and password if username == user_you_seek: password_of_user = password break
- When you use index access
username_password_list[0]
what do you see?
- What does break do in a loop?
- What happens, when the user is not inside the nested list? Do you think it's a good approach?
- Bonus question: What happens when the same user is twice in the list?
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!