User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 373,192 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,831 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 262 | Replies: 4
Reply
Join Date: May 2008
Posts: 38
Reputation: tondeuse34 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
tondeuse34's Avatar
tondeuse34 tondeuse34 is offline Offline
Light Poster

Lists & Passwords

  #1  
May 16th, 2008
Hey guys, I've came across problem and wondering say if you have a 2 lists called user_list and pass_list and you have a prompt for username and password. Instead of 1 user name and password how could it be for all can be used at the same prompt? heres an example of my code:
#Start of the program
print "Welcome To the Server!"
#Varible i'm using for later on in the program
a = 0

#The list of user names
user_list = ['sam','bob','tom']
#And list of passwords
pass_list1 = ['12','13','14']

#The prompt ofr the username and password
username = raw_input("Username: ") % user_list
if username =='user_list':
    password = raw_input("Password: ") % pass_list1
 if password.lower() == 'pass_list1':
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 10
Reputation: Capt.Micro is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Capt.Micro Capt.Micro is offline Offline
Newbie Poster

Re: Lists & Passwords

  #2  
May 17th, 2008
Hello, Looking at your code, you only need one thing changed, the if parts part.

#Start of the program
print "Welcome To the Server!"
#Varible i'm using for later on in the program
a = 0

#The list of user names
user_list = ['sam','bob','tom']
#And list of passwords
pass_list1 = ['12','13','14']

#The prompt ofr the username and password
username = raw_input("Username: ")
for user in user_list:
    if username == user:
        password = raw_input("Password: ")
for pass in pass_list1:
    if password.lower() == pass:
       <insert rest of code here>

If you have any more questions, just ask.
Last edited by Capt.Micro : May 17th, 2008 at 12:13 am.
Reply With Quote  
Join Date: Aug 2005
Location: England - York
Posts: 136
Reputation: a1eio is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 9
a1eio's Avatar
a1eio a1eio is offline Offline
Junior Poster

Re: Lists & Passwords

  #3  
May 17th, 2008
python has a keyword function in that would be useful in your example.

  1. if password in pass_list1:
  2. # do something
Reply With Quote  
Join Date: May 2008
Posts: 38
Reputation: tondeuse34 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
tondeuse34's Avatar
tondeuse34 tondeuse34 is offline Offline
Light Poster

Re: Lists & Passwords

  #4  
May 17th, 2008
Thanks guys for answering my question
Reply With Quote  
Join Date: May 2008
Posts: 38
Reputation: tondeuse34 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
tondeuse34's Avatar
tondeuse34 tondeuse34 is offline Offline
Light Poster

Re: Lists & Passwords

  #5  
May 17th, 2008
also, another quick question why does it print one thing 3 times?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Python Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 9:57 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC