• Register
Log In
0 votes

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.9k 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"

36.1k points
edited by

Related questions

0 votes
3 answers 824 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 9 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.2k points
1 vote
1 answer 13 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 5.7k points
1 vote
1 answer 11 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.2k points
1 vote
2 answers 17 views
Problem: I am very noob at programming language so I am doing my pracice on python. I tried to to replace multiple characters in a string in python. So I write this code: tes_str = "abababababababba" print("The main string is : " + str(tes_str)) res = tes_str('a', '%temp%')('b', ... = tes_str('a', '%temp%')('b', 'a')('%temp%', 'b') TypeError: 'str' object is not callable Can anyone help me out?
asked Apr 6 LizzyM 5.7k points