Python Forum
Unexpected character after line continuation character
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected character after line continuation character
#4
(Sep-05-2018, 06:07 AM)joshyb123 Wrote: my only question is why does the \n work when enclosed in quotes? Doesn't that denote a string type?
Exactly. A text between quotes is technically called a literal string. These strings may contain ordinary characters and some special characters that cannot be directly typed with a keyboard. They are entered with an escape sequence such as \n. When this escape sequence appears in a literal string, it is transformed in a single character named ASCII-linefeed.
(Sep-05-2018, 06:07 AM)joshyb123 Wrote: is there another way to accomplish this same output in a single print statement?
Yes there is, one can use the format() method
print('{} {}\n{} {}\n{}, {}  {}'.format(firstname, lastname, houseNumber, streetName, cityName, stateName, zipCode))
Reply


Messages In This Thread
RE: Unexpected character after line continuation character - by Gribouillis - Sep-05-2018, 06:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using regex to count specific character in file shamishd 1 1,668 Oct-01-2021, 07:33 AM
Last Post: snippsat
  Split string into 160-character chunks while adding text to each part iambobbiekings 9 9,736 Jan-27-2021, 08:15 AM
Last Post: iambobbiekings
  Replacing a few characters of a specified character but not all of them from a string fatherted99 7 3,325 Aug-13-2020, 09:08 AM
Last Post: fatherted99
  Change each character of list into an different characters Angry_bird89 1 2,091 Jun-19-2020, 08:29 AM
Last Post: Angry_bird89
  Search character from 2d list to 2d list AHK2019 3 2,547 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  Tab character in a string prints 8 spaces hecresper 6 20,807 Aug-27-2019, 02:38 PM
Last Post: snippsat
  Print strings enclosed with a character with different characters aylmaoxd 1 1,968 Aug-17-2019, 03:35 PM
Last Post: Resistance
  Finding and storing all string with character A at middle position Pippi 2 2,737 Jan-20-2019, 08:23 AM
Last Post: Pippi
  Remove special character from list vestkok 3 4,308 Nov-04-2018, 01:48 PM
Last Post: ichabod801
  unexpected character after line continuation character error newbie 10 14,829 Aug-09-2018, 06:07 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020