Re: insert chars into string

2006-03-18 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > hi > is there a string method to insert characters into a string? > eg > str = "abcdef" > i want to insert "#" into str so that it appears "abc#def" > > currently what i did is convert it to a list, insert the character > using insert() and then join them back as strin

Re: insert chars into string

2006-03-17 Thread Felipe Almeida Lessa
Em Sex, 2006-03-17 às 17:32 -0800, [EMAIL PROTECTED] escreveu: > is there a string method to insert characters into a string? As far as I know, no. Strings are immutable in Python. That said, the following method may do what you want: def insert(original, new, pos): '''Inserts new inside

insert chars into string

2006-03-17 Thread eight02645999
hi is there a string method to insert characters into a string? eg str = "abcdef" i want to insert "#" into str so that it appears "abc#def" currently what i did is convert it to a list, insert the character using insert() and then join them back as string.. thanks -- http://mail.python.org/mai