Sonia has a list called colleges with ten entries and wants to print the final item on the list. Which code should be used?
print(colleges[0])
print(colleges[-1])
print(colleges[10])
print(colleges[+1])

Respuesta :

The code to use to print the final item of a list called colleges is print(colleges[-1])

List:

List in python is used to store multiple items in a single variable. List can accept different data type such as Booleans, strings, integers, floats etc.

Example of a list is a s follows:

x = ["ade", 4, True]

According to the question, the list is called colleges. To print the last item in the list we have to use the index.

Therefore, let's use the code as an example

colleges  = ["Pomona", "Hamilton", "Middlebury", "Harvey Mudd"]

print(colleges[-1])

Running this code will print "Harvey Mudd" (the last item in the list)

Therefore, the code to use to print the final item of a list called colleges is print(colleges[-1])

learn more on python code here: https://brainly.com/question/25774782?referrer=searchResults

Ver imagen vintechnology