0
print('\r2021529,"Aren\'t you something to admire?\r\'Cause your shine is somethin\' like a mirror",,')

gives this output:

'Cause your shine is somethin' like a mirror",,

What? Why is the front of the string being chopped off? Can it have something to do with the quotes?

Louise
  • 1,063
  • 1
  • 9
  • 20
  • print repr(string_from_above) works fine! – Louise Oct 14 '15 at 14:51
  • What version of python do you use? When I execute this under 2.7.8 it prints everything. – PhillipD Oct 14 '15 at 14:53
  • >>> print('\r2021529,"Aren\'t you something to admire?\r\'Cause your shine is somethin\' like a mirror",,') 2021529,"Aren't you something to admire? 'Cause your shine is somethin' like a mirror",, – Joe T. Boka Oct 14 '15 at 14:53
  • Works perfectly fine for me – MohitC Oct 14 '15 at 14:54
  • I have the answer! \r is carriage return without newline. So this brings the caret back to the beginning of the line, at which point it overwrites the beginning of the string. This is in the iPython Notebook version delivered with Anaconda. – Louise Oct 14 '15 at 14:55
  • It happens in the Python 2.7 that ships with OS X too. – Louise Oct 14 '15 at 14:57

0 Answers0