Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace with newline python

Tags:

python

I have a string

a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"

I want print a as

">
NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"

I did a=a.replace(">","> \n") but it doesn't work. Where am I going wrong?

like image 781
Ank Avatar asked Jul 05 '11 07:07

Ank


1 Answers

One thing is the internal representation of the string:

>>> a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS"
>>> a.replace(">","> \n")
'> \nNKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS'

another one is how it will be shown on screen:

>>> print(a.replace(">","> \n"))
> 
NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS
like image 82
mac Avatar answered Oct 17 '22 12:10

mac