Ask Your Question
0

Integer not iterable

asked 9 years ago

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

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

Preview: (hide)
link

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 ( 9 years ago )

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: 9 years ago

Seen: 1,105 times

Last updated: Feb 27 '16