87260/syntaxerror-invalid-syntax-in-inline-function
Hi Guys,
I am trying to perform one task using the list comprehension concept. But it is showing the syntax error.
File "<ipython-input-9-f0c31b619ddf>", line 1 m = [i*i for i in x if i>0 else 0] ^ SyntaxError: invalid syntax
Hi@akhtar,
You need to write your if-else code before the for loop. But in your case, you have written after for loop. So you need to modify your code as shown below.
m = [i*i if i>0 else 0 for i in x]
If you're using Jupyter notebook, just mention this ...READ MORE
def Psat(self, T): pop= ...READ MORE
A "SyntaxError: invalid syntax" is a common ...READ MORE
but i m getting this ouput: Enter the ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Hi@akhtar, This syntax will not allow in all ...READ MORE
Thanks, This answer was helpful. READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.