ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 01 Jan 2021 21:26:29 +0100Keeping the word in a list of lettershttps://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/Sorry to ask a question whose answer is probably evident but i can't find the answer.
Running
Word(["A","B","C","D"])
returns `word : ABCD` when I want only `ABCD`.Thu, 31 Dec 2020 11:46:33 +0100https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/Answer by tmonteil for <p>Sorry to ask a question whose answer is probably evident but i can't find the answer.</p>
<p>Running</p>
<pre><code>Word(["A","B","C","D"])
</code></pre>
<p>returns <code>word : ABCD</code> when I want only <code>ABCD</code>.</p>
https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?answer=55027#post-id-55027When you type:
sage: w = Word(["A","B","C","D"])
sage: w
word: ABCD
what you get is the *representation* of the word `w`, you cant turn it into a string as follows:
sage: str(w)
'ABCD'
Thu, 31 Dec 2020 11:56:51 +0100https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?answer=55027#post-id-55027Comment by slelievre for <p>When you type:</p>
<pre><code>sage: w = Word(["A","B","C","D"])
sage: w
word: ABCD
</code></pre>
<p>what you get is the <em>representation</em> of the word <code>w</code>, you cant turn it into a string as follows:</p>
<pre><code>sage: str(w)
'ABCD'
</code></pre>
https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?comment=55049#post-id-55049Or use the `string_rep` method.
sage: w = Word(['A', 'B', 'C', 'D'])
sage: w.string_rep()
'ABCD'Fri, 01 Jan 2021 17:27:15 +0100https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?comment=55049#post-id-55049Answer by Sébastien for <p>Sorry to ask a question whose answer is probably evident but i can't find the answer.</p>
<p>Running</p>
<pre><code>Word(["A","B","C","D"])
</code></pre>
<p>returns <code>word : ABCD</code> when I want only <code>ABCD</code>.</p>
https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?answer=55062#post-id-55062You may remove the prefix `word: ` using the following option:
sage: WordOptions(identifier='')
sage: Word(["A","B","C","D"])
ABCDFri, 01 Jan 2021 21:26:29 +0100https://ask.sagemath.org/question/55026/keeping-the-word-in-a-list-of-letters/?answer=55062#post-id-55062