Sep-05-2018, 06:33 AM
(This post was last modified: Sep-05-2018, 06:41 AM by Gribouillis.)
(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()
methodprint('{} {}\n{} {}\n{}, {} {}'.format(firstname, lastname, houseNumber, streetName, cityName, stateName, zipCode))