• Register
0 votes
154 views

Problem :

In Python, code blocks are defined by the tabs, not by the ";" at the end of the line

if number > 10 and number < 25:
    print "1"

Is mutliple lines possible in python? like...

if number > 10 
and number < 25:
    print "1"

6 5 3
6,930 points

1 Answer

0 votes

Solution : 

PFB the solution for your problem

Method 1: Using parenthesis

if (number > 5 and
        number < 15):
    print "1"
Method 2: Using backslash
if number > 5 and \
number < 15:
    print "1"

Method 3: Using backslash + indent for better readability

if number > 5 and \
        number < 15:
    print "1"

9 7 4
38,600 points

Related questions

0 votes
3 answers 1.6K views
1.6K views
Problem : My Python program is giving below error python unexpected character after line continuation character
asked Oct 22, 2019 peterlaw 6.9k points
1 vote
1 answer 11 views
11 views
Problem: Hello guys, I have a big number of .csv file with full of data. I want to merge them all in a single file. It is a hectic job to copy all the data from each and compile into one single file. So, I am willing to combine multiple .csv files into one using ... me to do it. Thanks for your effort guys. Note: I named all the .csv files under a series. Let say they are named with data1-data100
asked Apr 6 Gavin 15.3k points
1 vote
1 answer 20 views
20 views
Problem: I have a python file that contains too many lines of code. I have written a code to count the total number of lines in a exact file. My code: def file_name(fname): with open(fname) as fn: for i, l in enumerate(fn): pass return i+1 Does the code give me the exact count ? If not how can I solve this?
asked Apr 5 LizzyM 6.1k points
1 vote
1 answer 14 views
14 views
Problem: Well, I have a text file containing thousands of lines possibly. I am willing to give them a count (if possible). What is the easiest and efficient way to write a program to get number of lines in a file python? Please, keep it simple so that I can understand the code easily. Thanks.
asked Mar 29 Gavin 15.3k points