ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 03 Aug 2016 09:09:29 -0500Create a set of numbers with a equatation and 2 diffrent variableshttp://ask.sagemath.org/question/34315/create-a-set-of-numbers-with-a-equatation-and-2-diffrent-variables/ I need to create a set of numbers which are defined by m in [0..41] and n in [100]. The new created set needs to contain all the numbers which fulfill that condition.
I tried to accomplish that with:
A=[n^2+n+m^2 for n in [1..100] and m in [0..41]]
But Sage takes the and as an bool value not as another condition. can you help me with that?
(First time programming and english is not my mother tongue. Please be pleasefull)
Thanks alot!Wed, 03 Aug 2016 08:36:49 -0500http://ask.sagemath.org/question/34315/create-a-set-of-numbers-with-a-equatation-and-2-diffrent-variables/Answer by vdelecroix for <p>I need to create a set of numbers which are defined by m in [0..41] and n in [100]. The new created set needs to contain all the numbers which fulfill that condition.</p>
<p>I tried to accomplish that with:</p>
<p>A=[n^2+n+m^2 for n in [1..100] and m in [0..41]]</p>
<p>But Sage takes the and as an bool value not as another condition. can you help me with that?</p>
<p>(First time programming and english is not my mother tongue. Please be pleasefull)</p>
<p>Thanks alot!</p>
http://ask.sagemath.org/question/34315/create-a-set-of-numbers-with-a-equatation-and-2-diffrent-variables/?answer=34317#post-id-34317Your Python syntax is indeed wrong. It should be
sage: A=[n^2+n+m^2 for n in [1..100] for m in [0..41]]
The "and" keyword is reserved for the binary operation.Wed, 03 Aug 2016 09:09:29 -0500http://ask.sagemath.org/question/34315/create-a-set-of-numbers-with-a-equatation-and-2-diffrent-variables/?answer=34317#post-id-34317