print("foo
bar")
"""
foo
bar
"""
print("line one
line two") # the
in python is used to create new lines in a string
# To print a newline in python Python has a special charecter as
with a
# string.
print("Hi
How are you")
#The output of This program is:
Hi
How are you
# But if you just print a new line like this:
print("
")
# The output of this program is Two newlines:
# It printed two newlines because if i say print("hi") and then print("hello")
# Python prints them in seperate lines.This means that Python automatically
# generates a newline with the print statement. So if we print("
") Python
# automattically generates a newline because of the print statement and then
# it prints a newline which gives us two blank lines. So print("
") therefore,
# gives you two blank lines.
# If you have to print a blank single newline you have to use print() or
# print("") What this blank print statement does is Python automatically
# generates a newline because of the print statement and then you print
# nothing. So print() or print("") gives you a blank single new line.
# When you want to print in a new line you can write '
' to indicate the start of the line
# Remember '
' is one character not two
stuff1 = 'Hello
World!'
print(stuff1) # Output: Hello
# World
stuff2 = 'X
Y'
print(stuff2) # Output: X
# Y
print(len(stuff2)) # Output: 3
print('
', end='')
print("First Line
" "Second Line")
#code
print('characters after the Python new line character
will be printed on a new line')
#output
characters after the Python new line character
will be printed on a new line
def refactoring_example(spellbook):
result = []
for spell in spellbook:
if spell.is_awesome:
result.append(spell)
return result