+ 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)
3 Answers
+ 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.
0
Still displaying same error
0
Preet Bhinder
Use my answer.. i have updated it