0
def test():
    var1 = "hello"
    var2 = "world"

    print(f"This is just a test so i dont know? Im gonna spam some word to it exceeds 80 characters maybe. is this more than enough already? Okay maybe. Just wanted to say, {var1}, {var2} to everyone!"

How do I break the print statement? If I break it using \ like below, it'll print out white spaces too.

def test():
    var1 = "hello"
    var2 = "world"

    print(f"This is just a test so i dont know? Im gonna spam some word to it exceeds \
                        80 characters maybe. is this more than enough already? Okay maybe. \
                        Just wanted to say, {var1}, {var2} to everyone!"
riazufila
  • 17
  • 1
  • 4

1 Answers1

0

You can eliminate the unwanted whitespaces by adjusting your indentation. Outside a function, you do it like this:

var1 = "hello"
var2 = "world"
print(f"This is just a test so i dont know? Im gonna spam some word to it exceeds \
80 characters maybe. is this more than enough already? Okay maybe. \
Just wanted to say, {var1}, {var2} to everyone!")

Inside a function, you do it like this:

def test():
    var1 = "hello"
    var2 = "world"

    print(f"This is just a test so i dont know? Im gonna spam some word to it exceeds \
80 characters maybe. is this more than enough already? Okay maybe. \
Just wanted to say, {var1}, {var2} to everyone!")
pakpe
  • 5,391
  • 2
  • 8
  • 23
  • This makes it look weird especially when the function is already very far to the right. but i guess that solves it. – riazufila Mar 20 '21 at 06:11