What is wrong here? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
22nd May 2018, 1:56 PM
B.D
B.D - avatar
2 Respuestas
+ 3
The first thing, which not be too big of an issue, is that you're using the & operator for comparison in the if statement. I would recommend using the Python 'and' statement instead for that. Second, when referring to items in a list, the index of the elements within them start counting at 0. This means that if you were wanting to retrieve the first item within your list, you would have to do something along the lines of listName[0]. Because you're setting two variables to be equal to the second element in the lists (list index -1 and 1 will retrieve the second element in a list with two items), all you're doing is subtracting 0 by 0, resulting in the answer being 0.00. I would recommend setting one of your variables to be equal to the element at list index 0 for both of your lists, as this should fix the problem. Hope this helped!
22nd May 2018, 2:13 PM
Faisal
Faisal - avatar
+ 2
Thank you
22nd May 2018, 4:40 PM
B.D
B.D - avatar