On Thu, Jul 16, 2009 at 5:50 AM, Kent Johnson wrote:
> On Thu, Jul 16, 2009 at 4:29 AM, Wayne wrote:> I have
> two different ways I can put _ in the word:
> > word = 'cat'
> >
> > ''.join(list(word)[1] = '_')
>
> Not in any Python I ever used...
> In [1]: word = 'cat'
>
> In [2]:
>
> In [3]: ''.j
On Thu, Jul 16, 2009 at 4:29 AM, Wayne wrote:
> Hi,
>
> My question is more about style/timing than anything else.
>
> In my program I'm taking a word and generating "blanks" in that word. For
> example, the word cat could generate:
> _at
> c_t
> ca_
>
> I have two different ways I can put _ in the
On Thu, Jul 16, 2009 at 11:22 AM, Gregor Lingl wrote:
> That's simply not true in Python. Try it out!
>
word = "cat"
word[1] = "_"
> Traceback (most recent call last):
> File "", line 1, in
> word[1] = "_"
> TypeError: 'str' object does not support item assignment
And the reason for
Christian Witts schrieb:
Wayne wrote:
Hi,
...
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Strings are essentially a list already of
Wayne wrote:
On Thu, Jul 16, 2009 at 4:06 AM, Christian Witts
mailto:cwi...@compuscan.co.za>> wrote:
Strings are essentially a list already of characters. What would
be slowing down your preferred method #1 would be your explicit
cast to a list and then re-joining that list
Wayne wrote:
Hi,
My question is more about style/timing than anything else.
In my program I'm taking a word and generating "blanks" in that word.
For example, the word cat could generate:
_at
c_t
ca_
I have two different ways I can put _ in the word:
word = 'cat'
''.join(list(word)[1] = '_'
Hi,
My question is more about style/timing than anything else.
In my program I'm taking a word and generating "blanks" in that word. For
example, the word cat could generate:
_at
c_t
ca_
I have two different ways I can put _ in the word:
word = 'cat'
''.join(list(word)[1] = '_')
and
# I'm not