Justin
Justin

Reputation: 1479

How to make print statement one line in python?

How do i make this code print as one line?:

 print("If a hippo ways 2000 pounds, gives birth to a 100 pound calf and
          then eats a 50 pound meal how much does she weigh?")

I have it this way to make it more readable, i know i could use triple quotes to get it to print exactly the way it is and that i could use a comma to separate the statement into two lines, but that would make two separate strings(I think). is there a way to keep the statement as one string and have it print out as one line?

Upvotes: 4

Views: 147

Answers (2)

user395760
user395760

Reputation:

Adjacent string literals are concatenated implicitly:

print("If a hippo ways 2000 pounds, gives birth to a 100 pound calf and "
       "then eats a 50 pound meal how much does she weigh?")

Upvotes: 13

GHL
GHL

Reputation: 572

print("If a hippo ways 2000 pounds, gives birth to a 100 pound calf and "\
      +"then eats a 50 pound meal how much does she weigh?")

Upvotes: 1

Related Questions