Ask Your Question
1

Keeping the word in a list of letters

asked 2020-12-31 11:46:33 +0200

Cyrille gravatar image

updated 2021-01-01 17:24:07 +0200

slelievre gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2020-12-31 11:56:51 +0200

tmonteil gravatar image

When 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'
edit flag offensive delete link more

Comments

Or use the string_rep method.

sage: w = Word(['A', 'B', 'C', 'D'])
sage: w.string_rep()
'ABCD'
slelievre gravatar imageslelievre ( 2021-01-01 17:27:15 +0200 )edit
1

answered 2021-01-01 21:26:29 +0200

Sébastien gravatar image

updated 2021-01-01 21:27:14 +0200

You may remove the prefix word: using the following option:

sage: WordOptions(identifier='')                                                
sage: Word(["A","B","C","D"])                                                   
ABCD
edit flag offensive delete link more

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: 2020-12-31 11:46:33 +0200

Seen: 204 times

Last updated: Jan 01 '21