I’m working through a project within the Python 3 course.
I’m not returning an error. My question is more related to how I can concatenate strings and not have them “squished together”. For example, on line 19, I created a variable and then I continue to use plus-equal to add to this variable (adding descriptions of the each items purchased)
customer_one_itemization = ""
Customer One Items:
Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade.
For a cleaner look, I’d like to have Lovely Loveseat along with its description together and then Luxurious Lamp and its description on another line instead of appended to the end of the description for “Lovely Loveseat”
Customer One Items:
Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.
Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade.
I’m going to add on to what @java9048199302 and @seraph776 have said here. We should know the function and the way in which aspects of our code work rather than adding them in without understanding their mechanisms.
\n is an escape sequence. Escape sequences begin with a backslash (\) and are followed by a character or set of characters, with different characters resulting in different outputs (see the table below). \n is the newline escape sequence and moves the cursor down to the next line.
Here’s a list of all the recognized escape sequences in Python (find more about them here).
Backslash and newline ignored
Backslash ( \ )
Single quote ( ' )
Double quote ( " )
ASCII Bell (BEL)
ASCII Backspace (BS)
ASCII Formfeed (FF)
ASCII Linefeed (LF)
ASCII Carriage Return (CR)
ASCII Horizontal Tab (TAB)
ASCII Vertical Tab (VT)
Character with octal value ooo
Character with hex value hh
Side note: \n is called the newline escape sequence but inserts an ASCII linefeed (as indicated by the table above) because of terminology that was used when typewriters were commonly used. You can learn more about it for your own pleasure here.