I'm trying to print out some values according to a sequence rule n(n+1)/2 from another list, I have so far:
for i in range(0,5):
print LHS[(i(i+1))/2]
Why should this not work but print LHS[i]
be fine?
However this is raising the error in the title. I do not understand why this would not work in Python.
If anybody could help I would be very grateful!!
You forgot an operator here:
i(i+1)
Python interprets that as a call expression; i
must be a callable, passing in i+1
as the single argument. Since i
is an integer instead, which is not callable, you get an exception.
Perhaps you meant:
i * (i+1)
您试图将“ i”作为函数i(i + 1)调用
也许您是说:i *(i + 1)?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.