2 Replies - 498 Views - Last Post: 21 October 2012 - 07:17 AM Rate Topic: -----

#1 SaDestro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-October 12

IndexError:index out of range

Posted 20 October 2012 - 07:23 AM

Hi all i new to python ...i am trying to read values from a file named "userid.txt".The values are kept in form
USERNAME,PASSWORD.....but when i am running the code i get indexerror:index out of range -1
userid = []
password = []


file = open( sys.path[0] + "\userid.txt" , "r")
for line in file:
    temp = line.split(",")
    userid.append(temp[0].strip())
    password.append(temp[1].strip())
    
file.close()

id = userid[grinder.threadNumber]
pw = password[grinder.threadNumber] 
print id ,pw


This post has been edited by atraub: 20 October 2012 - 01:00 PM
Reason for edit:: added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: IndexError:index out of range

#2 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,682
  • Joined: 13-March 10

Re: IndexError:index out of range

Posted 20 October 2012 - 09:25 AM

Post your exact errors and post the code inside code tags. Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

Re: IndexError:index out of range

Posted 21 October 2012 - 07:17 AM

Also, what is grinder.threadNumber? You're using it as an index, so it could potentially be causing the error, but since I have no idea what it is... I can't really help there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1