473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TypeError: 'type' object is not subscriptable

1 New Member
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
1 35834
dwblas
626 Recognized Expert Contributor
"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

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

Similar topics

1
by: Atul Kshirsagar | last post by:
Hello, I am using Python 2.3.2 with a C++ extention DLL in muti-threaded environment. 1. For each new thread I create a separate sub-interpreter. 2. Each thread executes multiple python...
2
by: Balaji | last post by:
Hello Everybody... I have a problem.. This is the code... -------------------------------------- class Stack: def __init__(self,expr): self.stackP=
5
by: Randall Parker | last post by:
Using Python 2.4.2 on Windows 2000 in SPE. Getting: TypeError: 'str' object is not callable on this line: TmpErrMsg1 = "State machine %s " (StateMachineName) In Winpdb 1.0.6 the...
9
by: k.retheesh | last post by:
Can anybody tell me why am I getting this error message while trying to print a part of a string. Is there a better approach for this... Traceback (most recent call last): File...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
33
by: christophertidy | last post by:
Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I...
1
by: Charles Fox | last post by:
Hi gys -- I am looking at Numpy but getting this error when I try to get array sizes. I'm using Ubuntu Edgy with standard repositories and scipy. Any ideas? Am I doing something wrong or is it...
1
by: mankeluvsit | last post by:
hey everyone, for reasons, i needed to grap information from steampowered.com from BeautifulSoup import BeautifulSoup from urllib import urlopen import re import codecs html_text =...
1
by: Gonzalo Gonza | last post by:
When I execute this code (if the number finishes in 2 returns true, else none) def asdf(n): n=str(m) elif m==2: return True I get the following Error: Traceback (most recent call...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.