Error of some kind

Thread Solved

Join Date: Jul 2005
Posts: 10
Reputation: madgokuss4 is an unknown quantity at this point 
Solved Threads: 0
madgokuss4 madgokuss4 is offline Offline
Newbie Poster

Error of some kind

 
0
  #1
Jul 10th, 2005
I have been working on some python code with a friend and for some reason i keep getting this message when i try to run his code,

if ar[2]!="client":
IndexError: list index out of range

I can't see whats wrong and i have never had this message come up before??
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,013
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 929
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Error of some kind

 
0
  #2
Jul 10th, 2005
What does ar look like?
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 10
Reputation: madgokuss4 is an unknown quantity at this point 
Solved Threads: 0
madgokuss4 madgokuss4 is offline Offline
Newbie Poster

Re: Error of some kind

 
0
  #3
Jul 11th, 2005
All there is to the client line is this : if ar[2]!="client":
Thats it there is nothing else there, i have asked my friend and he reckons it works for him. I have tried some examples i found on the net and if they have any "ar" in them they don't seem to work. I have tried uninstalling all my python stuff and doing a fresh install and that doesn't seem to make any difference either.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,013
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 929
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Error of some kind

 
0
  #4
Jul 11th, 2005
You need to put some elements into the ar list ...
  1. ar = [] # empty list gives IndexError: list index out of range
  2.  
  3. #ar = ["cl", "cli", "clien"] # properly loaded list will work
  4.  
  5. if ar[2]!="client":
  6. print "not client"
Last edited by vegaseat; Oct 25th, 2009 at 2:16 pm. Reason: updated old [php] code tags
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 10
Reputation: madgokuss4 is an unknown quantity at this point 
Solved Threads: 0
madgokuss4 madgokuss4 is offline Offline
Newbie Poster

Re: Error of some kind

 
0
  #5
Jul 11th, 2005
R now i see what's wrong, all i got to say is thank god there are sites like this and good people like you to help vegaseat :mrgreen:


P.S I'll see you when i come across my next problem
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC