Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Notes and Multi-Line strings in Python
- #—————————
- Let’s say we want to create a note to tell the user/viewer about the code, or as a self reminder.
- We can do that within our code using the following syntax:
- # this is a note
- 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
- be contained within your workspace for notice/information or whatever you may need.
- Now, Multi-Line strings!
- Let’s say we have an extremely large string.
- 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”
- # note that this string takes up multiple lines
- 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.
- Therefore, the correct syntax for this multi-line string will be:
- 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