193k views
1 vote
Initialize a list. ACTIVITY Initialize the list short.names with strings 'Gus', Bob, and 'Ann'. Sample output for the given program Gus Bob Ann 1 short_names- Your solution goes here 2 # print names 4 print(short_names[0])

User Jianwei
by
6.2k points

1 Answer

1 vote

Answer:

shortNames = ['Gus', 'Bob','Zoe']

Step-by-step explanation:

In this assignment, your knowledge of list is been tested. A list is data structure type in python that can hold different elements (items) of different type. The general syntax of a list is

listName = [item1, "item2", item3]

listName refers to the name of the list variable, this is followed by a pair of square brackets, inside the square brackets we have items separated by commas. This is a declaration and initialization of a list with some elements.

The complete python code snippet for this assignment is given below:

shortNames = ['Gus', 'Bob','Zoe']

print(shortNames[0])

print(shortNames[1])

print(shortNames[2])

User Jbwharris
by
6.0k points