0

Why does this code not work?: value=[1] value2=[2] if value==1 and value2==2: print("successful")

24th Aug 2016, 6:05 PM
Ezie
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.
30th Aug 2016, 6:15 AM
Cornel
Cornel - avatar
+ 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")
24th Aug 2016, 6:17 PM
Amarie
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?)))
24th Aug 2016, 8:21 PM
ŠšŠ¾Š½ŃŃ‚Š°Š½Ń‚ŠøŠ½ Š˜Š²Š°Š½Š¾Š²
ŠšŠ¾Š½ŃŃ‚Š°Š½Ń‚ŠøŠ½ Š˜Š²Š°Š½Š¾Š² - avatar
0
using brackets mean it is a list. you should use : if value in 1 and value2 in 2: print("success")
27th Aug 2016, 2:30 AM
Ai Jogja
0
your values shouldn't be in a brackets as they are integer's. and the if and & statement should be in 1 line.
30th Aug 2016, 9:08 PM
smith mallick
smith mallick - avatar
0
how to use lists .. .!
15th Sep 2016, 4:45 AM
Nirmal jose
Nirmal jose - avatar