0
Why does this code not work?: value=[1] value2=[2] if value==1 and value2==2: print("successful")
6 Answers
+ 3
your values are initiated as lists. Your if statement compared if list equals integer. that is false so no output. The code is correct but the if statement isn't satisfied.
if you wanted the output, correct the code as @amarie suggested.
+ 2
1.You shouldn't use brackets for integers.
2. The if- and and statement have to be in one line.
value=1
value2=2
if value==1 and value2==2:
print("successful")
0
You should use indexes:
value=[1]
value2=[2]
if value[0]==1 and value2[0]==2:
print("Success!!!")
because your vars is a lists. You mast use indexes of lists if you wants to get its data. Isnt it?)))
0
using brackets mean it is a list.
you should use :
if value in 1 and value2 in 2:
print("success")
0
your values shouldn't be in a brackets as they are integer's. and the if and & statement should be in 1 line.
0
how to use lists .. .!