3

This is the line of code I want to break up, it works fine but it is a very long line, how does one use line breaks in a format function print line like this?

return '{0.name} is a {0.sex} rabbit and has {0.fur_colour} fur and {0.eye_colour} eyes, {0.name} is of the {0.breed} breed of rabbits.\n{0.name} is '.format(paul)+ disp_age
CDJB
  • 14,043
  • 5
  • 29
  • 55
Susan
  • 238
  • 3
  • 11

1 Answers1

2

You could store your whole splitted string into ()

return ("{0.name} is a {0.sex} rabbit"
    " and has {0.fur_colour} fur and "
    "{0.eye_colour} eyes, {0.name} is "
    "of the {0.breed} breed of rabbits.\n"
    "{0.name} is ").format(paul)+ disp_age

This answer about multi-line strings was useful: https://stackoverflow.com/a/10660443/7042357

Kevin Lemaire
  • 949
  • 2
  • 12
  • 36