Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Notes and Multi-Line strings in Python
  2. #—————————
  3.  
  4. Let’s say we want to create a note to tell the user/viewer about the code, or as a self reminder.
  5.  
  6. We can do that within our code using the following syntax:
  7. # this is a note
  8.  
  9. Take notice that this code will be greyed out within most editors, and will not be ran as any type of code. It will just
  10. be contained within your workspace for notice/information or whatever you may need.
  11.  
  12. Now, Multi-Line strings!
  13.  
  14. Let’s say we have an extremely large string.
  15.  
  16. my_large_string = “aaaaa is the time for a great job of this week or so much for a great year of this year and ya know what you mean by the way I wanna know how you’re much fun of the day you have a great job I know you’re gonna I’m sorry was a really sad”
  17. # note that this string takes up multiple lines
  18.  
  19. If we attempt to use/run this variable/code, the console will return an error. This is because the string is longer than one line, and it hasn’t been defined as a multi-line string. To begin/end a multi-line string, you’ll need to use “”” or ‘’’, please note that within a string, the beginning and ending “ or ‘ need to be the same. For an example, “a’ will return an error, while “a” will work. This rule applies to multi line strings, too.
  20.  
  21. Therefore, the correct syntax for this multi-line string will be:
  22.  
  23. my_large_string = “”” aaaaa is the time for a great job of this week or so much for a great year of this year and ya know what you mean by the way I wanna know how you’re much fun of the day you have a great job I know you’re gonna I’m sorry was a really sad”””
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement