PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 22, 2022

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

 November 22, 2022     if-statement, indentation, multiple-conditions, python, python-3.x     No comments   

Issue

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?


Solution

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


Answered By - datamansahil
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing