+ 1

this programme is displaying invalid syntax error..plz help

x=input evens=int[i**2 for i in range(x) if i**2%2==0] print(evens)

21st Nov 2020, 3:40 PM
Preet Bhinder
Preet Bhinder - avatar
3 Respostas
+ 4
method 1- x=input() evens=[i**2 for i in range(int(x)) if i**2%2==0] print(evens) method 2- x=int(input()) evens=[i**2 for i in range(x) if i**2%2==0] print(evens) error 1 - Input is a function, so parentheses are required. error 2 - input() returns string.. so interpret it to int first.. or inside range() function, as range requires int.
21st Nov 2020, 3:41 PM
Charitra
Charitra - avatar
0
Still displaying same error
21st Nov 2020, 3:47 PM
Preet Bhinder
Preet Bhinder - avatar
0
Preet Bhinder Use my answer.. i have updated it
21st Nov 2020, 3:48 PM
Charitra
Charitra - avatar