I got feed back saying" list object is not callable". But I can't figure out
what is wrong with my code.
A=[3,5,4,9,6,7]
l=len(A)-1
for i in range(l):
print A(i) 4 1354
"Dongsheng Ruan" <ru**@jcmills.comwrites:
for i in range(l):
print A(i)
Use square brackets, A[i].
Usually we'd write such a loop like this:
for x in A:
print x
On Wednesday 07 February 2007 12:43:34 Dongsheng Ruan wrote:
I got feed back saying" list object is not callable". But I can't figure
out what is wrong with my code.
for i in range(l):
print A(i)
You're calling A, when you want to access one of its elements: use the
straight brackets [
for i in range(l):
print A[i]
Dongsheng Ruan a écrit :
I got feed back saying" list object is not callable". But I can't figure out
what is wrong with my code.
A=[3,5,4,9,6,7]
l=len(A)-1
for i in range(l):
print A(i)
The error message is quite clear when you remember that () is the call
operator. For the subscribe operator, you want [].
And FWIW, Python for loops are smarter than that:
A = [3,5,4,9,6,7]
for i in A:
print i
On Feb 8, 4:43 am, "Dongsheng Ruan" <r...@jcmills.comwrote:
I got feed back saying" list object is not callable". But I can't figure out
what is wrong with my code.
A=[3,5,4,9,6,7]
l=len(A)-1
for i in range(l):
print A(i)
What the others said, *plus*:
(1) you are subtracting 1 off the length, so after the change from ()
to [], the last item would not be printed.
(2) have you considered working through a tutorial?
Cheers,
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Mike Henley |
last post by:
I first came across rebol a while ago; it seemed interesting but then
i was put off by its proprietary nature, although the core of the
language is a free download.
Recently however, i can't...
|
by: Michele Simionato |
last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self
or other prototype-based languages. Still, from the discussion on the
mailing list, I have got the strong impression that...
|
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Leonard J. Reder |
last post by:
Hello Mark,
I took your three day course here at JPL and recall that you said
something was wrong with the implementation of threads within Python
but I cannot recall what. So what is wrong...
| |
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very...
|
by: Nathan Pinno |
last post by:
Hi all,
What's wrong with the following code? It says there is name error, that
random is not defined. How do I fix it?
# Plays the guessing game higher or lower.
# Originally written by Josh...
|
by: kishkin |
last post by:
Hello everyone!
I wanted to write python script with defined function. From that script
I wanted to call C module, which in it's turn call defined python
function. Sounds simple. But I've got...
|
by: emrahayanoglu |
last post by:
Hello Everyone,
Now, I'm working on a new web framework. I tried many test on the other
programming languages. Then i decided to use python on my web framework
project.
Now i want to listen...
|
by: Pyenos |
last post by:
import cPickle, shelve
could someone tell me what things are wrong with my code?
class progress:
PROGRESS_TABLE_ACTIONS=
DEFAULT_PROGRESS_DATA_FILE="progress_data"
PROGRESS_OUTCOMES=
|
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,...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |