简体   繁体   中英

TypeError: unsupported operand type(s) for +: 'function' and 'int'

Why this function call is giving me the above error?

count=0
def returncall():
  for i,j in enumerate(range(count,count+3),0):
    print i,j
  return j
count=returncall
print count()

The problem is here:

for i,j in enumerate(range(count,count+3),0):

count is another name for returncall because you have done count = returncall . returncall is a function; in fact, it's the very function that statement is in. You can't add an integer to a function ( count+3 ) because that is meaningless.

I don't really understand what you're attempting to do here, so can't really offer further advice. But that's what the error message means.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM