Hi Alex, On Mon, Jan 25, 2010 at 3:48 AM, Alex P <[email protected]> wrote: > | Sage Version 4.2.1, Release Date: 2009-11-14 | > Hi, > I was trying the code below and I was wondering how not to get an > ERROR. > ~Alex > > > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > sage: STR = 'ABCDEF' > sage: str = 'abcdef'
"str" is a built-in function of Python, so you should avoid re-assigning "str" to anything. See http://docs.python.org/library/stdtypes.html#string-methods for more information on "str". I don't get the error you reported at all: [mv...@sage sage-4.2.1]$ ./sage ---------------------------------------------------------------------- | Sage Version 4.2.1, Release Date: 2009-11-14 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: STR = "ABCDEF" sage: str = "abcdef" sage: for a in range(0, 5): ....: STR[a] ....: 'A' 'B' 'C' 'D' 'E' sage: for aa in range(0, 5): ....: str[aa] ....: 'a' 'b' 'c' 'd' 'e' However, you can also do this: sage: mySTR = "ABCDEF" sage: mystr = "abcdef" sage: for s in mySTR: ....: print s ....: A B C D E F sage: for ss in mystr: ....: print ss ....: a b c d e f -- Regards Minh Van Nguyen -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
