0

I'm a newbie scriptwriter and I was testing out my script using the interactive shell -i.

This is part of my script:

shelp = "min               shows the number of minutes\n\
sec               shows the number of seconds\n\
min + [NUMBER]    adds the number of minutes\n\
sec + [NUMBER]    adds the number of seconds"

When I run shelp in interactive, it shows:

'min               shows the number of minutes\nsec               shows the number of seconds\nmin + [NUMBER]    adds the number of minutes\nsec + [NUMBER]    adds the number of seconds'

I'm not sure if this is what it is supposed to do but is there a way to remove the \n while still be able to run my script in interactive?

Sorry if this is had already been answered or if I got my facts wrong

  • How do you print your shelp binding? Only print() function convert `\n` character into an endline. – diegoperini May 27 '13 at 04:15
  • 1
    you could use triple-quotes `"""for multiline strings"""` instead of `\n\` at the end of each line – jfs May 27 '13 at 04:21

1 Answers1

1

It sounds like you are looking for print():

>>> print(shelp)
min               shows the number of minutes
sec               shows the number of seconds
min + [NUMBER]    adds the number of minutes
sec + [NUMBER]    adds the number of seconds
>>>

The \n represents a newline and is where the line breaks if you use print(). If you just type shelp by itself, the interactive shell prints the representation of the string, which uses \n to show where the line breaks will go.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285