Coffee Guy
Coffee Guy

Reputation: 155

How to put two lines to run in a if statement in a single line

How to add two lines of code to run in a if statement in python 3 but still in one line?

What I am trying to do is that i have two lines of code

print('Yes')
print('This is a dumb question')

And i have to run them in a if statement, like

if cat == "meow":
    print('Yes')
    print('This is a dumb question')

So i can do it in one line like

if cat == "meow":print('Yes')

Now i have to put the second print statement to the if statement while still maintaining it in 1 line, Can i do this?

Upvotes: 0

Views: 649

Answers (1)

datamansahil
datamansahil

Reputation: 412

if cat == "meow":print('Yes'); print('This is a dumb question')

Upvotes: 3

Related Questions