been trying to wrap entire code in a comment, how do i do that? i tried #, """, with no success, and as a question, is this even possible? i guess im stacking comments on top of other comments but im sure there is a way, im wrapping this code because i want to keep it in one file along with other projects in the same file but i dont want to activate ALL of the code. here's the code i want to wrap as a comment:
"""Artithmetic expressions"""
addition = 1 + 1;
subtraction = 2-1;
miltiplication = 2*2;
division = 5/3; """5/3 = 1"""
"""Variables and Assignment"""
a, b = addition, subtraction; """a = addition, b = subtraction"""
""" prints 2 1"""
print a, b
"""Strings, indexing strings"""
string1 = "hello world hell"
string2 = string1[2]
"""prints 1"""
print string2
"""string extraction"""
string3 = string1[0:5]
""" hello """
print string3
"""Finding"""
stringfind1 = string1.find("hell", 4)
""" prints 12 """
print stringfind1
"""Python 2"""
"""If statement"""
if (3 < 10):
print "true"
else:
print "false"
""" Logical Operators"""
if (3 and 4 < 10):
print "true"
"""may use or"""
"""Loops, ex prints 10 iterations"""
count = 0
while (count < 10):
print 'The count is: ', count
count = count + 1
print "Good bye!"
"""converting between numbers and strings: str(one) converts int to string"""
"""use 'ord' for string --> int, lastly chr = """
one = 1
convert = str(one)
if convert == 1:
print "true"
else:
print "false"
'''returns one character string from number input'''
var1 = chr(65)
print var1
"""splitting strings: () prints all words in a string"""
""" ' ', 1 prints all except the last word?"""
string10 = "fucking hell i hate your life"
var2 = string10.split()
print var2
print string10.split(' ', 1)
"""Looping through strings with 'for' loop, ex prints all chars in 'string10' in new lines"""
for fuckoff in string10:
print 'Current letter :', fuckoff
After seven years of being not right answered here the right answer to the question above:
It will not always be possible (if the code uses both kinds of triple quoted strings), but in the case of code in the question it is possible to use '''
single quoted triple quoted string to achieve what you are after.
Below how it looks like:
'''
"""Artithmetic expressions"""
addition = 1 + 1;
subtraction = 2-1;
miltiplication = 2*2;
division = 5/3; """5/3 = 1"""
"""Variables and Assignment"""
a, b = addition, subtraction; """a = addition, b = subtraction"""
""" prints 2 1"""
print a, b
"""Strings, indexing strings"""
string1 = "hello world hell"
string2 = string1[2]
"""prints 1"""
print string2
"""string extraction"""
string3 = string1[0:5]
""" hello """
print string3
"""Finding"""
stringfind1 = string1.find("hell", 4)
""" prints 12 """
print stringfind1
"""Python 2"""
"""If statement"""
if (3 < 10):
print "true"
else:
print "false"
""" Logical Operators"""
if (3 and 4 < 10):
print "true"
"""may use or"""
"""Loops, ex prints 10 iterations"""
count = 0
while (count < 10):
print 'The count is: ', count
count = count + 1
print "Good bye!"
"""converting between numbers and strings: str(one) converts int to string"""
"""use 'ord' for string --> int, lastly chr = """
one = 1
convert = str(one)
if convert == 1:
print "true"
else:
print "false"
'''returns one character string from number input'''
var1 = chr(65)
print var1
"""splitting strings: () prints all words in a string"""
""" ' ', 1 prints all except the last word?"""
string10 = "fucking hell i hate your life"
var2 = string10.split()
print var2
print string10.split(' ', 1)
"""Looping through strings with 'for' loop, ex prints all chars in 'string10' in new lines"""
for fuckoff in string10:
print 'Current letter :', fuckoff
'''
You can see the evidence that it works as expected from the kind of highlighting of the above piece of code in its code textbox.