By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 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()]
  4.  
  5. sorted(thelist, key=lambda line : line[2])
  6.  
  7. other_list = []
  8.  
  9. initial_time = int(list[0][2]) 
  10.  
But shows error as
File "script.py", 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: 613
"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 http://www.dotnetperls.com/sort-python
Nov 1 '15 #2

Post your reply

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