By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,948 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,948 IT Pros & Developers. It's quick & easy.

TypeError: 'type' object is not subscriptable

P: 1
i have a python code..
Expand|Select|Wrap|Line Numbers
  1. thelist = []
  2. with open('rollernet.txt') as f:
  3.     thelist =[list(map(int,x.split())) for x in f.readlines()]
  5. sorted(thelist, key=lambda line : line[2])
  7. other_list = []
  9. initial_time = int(list[0][2]) 
But shows error as
File "", line 14, in <module>
initial_time = int(list[0][2]) #
TypeError: 'type' object is not subscriptable

what to do with this
Nov 1 '15 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 626
"list" is a type, like "int". The only thing you have declared in the program is "thelist". Note also that the "sorted" line does nothing. Print thelist to see for yourself and then see the sorted example at
Nov 1 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.