0
Does anyone know what is wrong with the line: print(areas.index[2]) where I'm trying to use the built in function to print the s
# Create list areas areas = [11.25, 18.0, 20.0, 10.75, 9.50] # Print out the index of the element 20.0 print(areas[2]) print(areas.index[2])
2 odpowiedzi
0
That's because you used square brackets instead of parentheses when using the index() function.
The syntax of the index() method is:
list.index(element)
where the parameter 'element' is the element that is to be
searched.
So your code should be like this:
print(areas.index(20.0))