-4

I dunno whats the purpose of this \n in python

Here is an example shown below:

 rangeNum = int(raw_input("Enter the max number you'd like to go up to: \n"))
Billy
  • 5,179
  • 2
  • 27
  • 53
Duvall912
  • 63
  • 6

1 Answers1

0

It is a special ASCII character signifying the end of a line of text and the start of a new line.

Alexander
  • 12,424
  • 5
  • 59
  • 76
  • ... and more of them that Python supports in its string literals can be found here https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals Scroll down to the 'Escape sequence' table. – Irmen de Jong Nov 21 '16 at 13:41
  • In what way is it an ASCII character? – Martin Bonner supports Monica Nov 21 '16 at 13:50
  • 1
    @MartinBonner: Because it's defined like that. Have a look at the [Table of Control Characters](https://en.wikipedia.org/wiki/ASCII#Control_characters). – Matthias Nov 21 '16 at 13:53
  • @Matthias: I am pretty sure that Python will map `\n` to whatever the underlying C implementation uses for `\n`. That may be LF, or on older Macs it may be CR. I have no idea what it is on EBCDIC mainframes, it will be. Saying that `\n` is **A** ASCII character is wrong. "A special character signifying ... " would be fine. – Martin Bonner supports Monica Nov 21 '16 at 14:23
  • According to the Python documentation the correct wording would be: [The meaning of `\n`is _ASCII Linefeed (LF)_](https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals). – Matthias Nov 21 '16 at 14:44