228k views
5 votes
Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the given program:

Gus
Bob
Zoe
1 short_names - "Gus[0]
2 short_names - 'Bob [1]
3 shortt_names - "Zoe[2]
4
5 print (short names[0])
6 print (short names[1])
7 print (short names[2])

1 Answer

6 votes

Answer:

Following are the correct code to this question:

short_names=['Gus','Bob','Zoe']#defining a list short_names that holds string value

print (short_names[0])#print list first element value

print (short_names[1])#print list second element value

print (short_names[2])#print list third element value

Output:

Gus

Bob

Zoe

Step-by-step explanation:

  • In the above python program code, a list "short_names" list is declared, that holds three variable that is "Gus, Bob, and Zoe".
  • In the next step, the print method is used that prints list element value.
  • In this program, we use the list, which is similar to an array, and both elements index value starting from the 0, that's why in this code we print "0,1, and 2" element value.
User Inshallah
by
4.7k points