• Register
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 5 3
6,930 points

Please log in or register to answer this question.

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.9K 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 15 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, 2020 Gavin 15.3k points
1 vote
1 answer 24 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, 2020 LizzyM 6.1k points
1 vote
1 answer 16 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, 2020 Gavin 15.3k points
0 votes
1 answer 65 views
I am new to python programming. I was trying to compare two strings, I wrote a code to compare: YourStr = "one" MyStr = "one" if YourStr = MyStr print("Two strings are same") else print("Two strings are not same") But it gives an error: File "main.py", line 4 if YourStr = MyStr ^ SyntaxError: invalid syntax Whats wrong in my code and how can I compare two string but it is not case sensitive?
asked Mar 16, 2020 LizzyM 6.1k points
0 votes
2 answers 793 views
Problem : Currently I am using the Python 3.3 and I have only entered these 3 below lines: import sklearn as sk import numpy as np import matplotlib.pyplot as plt But I am facing below error: “SyntaxError: multiple statements found while compiling a single statement” What is wrong with my Python code?
asked Jan 14, 2020 jwilliam 3.9k points
0 votes
1 answer 26 views
1 vote
2 answers 38 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, 2020 LizzyM 6.1k points