Ask Your Question
0

Integer not iterable

asked 2016-02-27 02:09:54 +0200

gerry_chuck gravatar image

Not sure if this was asked before. I've been going through the Sage and Python tutorials for the past 3 weeks as I worked out that I'll eventually have to learn at least some Python so to get what I need from Sage. So far so good,

But this one escapes me. The Sage tutorial refers to this example in The Python library:

map(mul, [0, 1, 2, 3], [10, 20, 30, 40]) which is supposed to yield [0, 20, 60, 120]

However, I keep getting ... ... TypeError: 'sage.rings.integer.Integer' object is not iterable

What's causing this?

Hope someone can help Gerry

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-02-27 02:16:53 +0200

gerry_chuck gravatar image

Yep, silly me, worked it out. Few lines below on the same page it says to enter the following command:

from operator import mul

Hope someone who uses the same approch in Learning sage finds this useful.

Gerry

edit flag offensive delete link more

Comments

1

In conjunction with map() I would prefer an anonymous function (lambda function):

map(lambda x,y:x*y, [0, 1, 2, 3], [10, 20, 30, 40])
ndomes gravatar imagendomes ( 2016-02-27 18:07:19 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-02-27 02:09:54 +0200

Seen: 652 times

Last updated: Feb 27 '16