Knowee
Questions
Features
Study Tools

Which of the following codes is correct for creating a list of names?AnameList = John, Harry, Jesse, John, Harry, HarryBnameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")CnameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]DnameList = [John, Harry, Jesse, John, Harry, Harry]

Question

Which of the following codes is correct for creating a list of names?AnameList = John, Harry, Jesse, John, Harry, HarryBnameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")CnameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]DnameList = [John, Harry, Jesse, John, Harry, Harry]

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct code for creating a list of names is:

CnameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

This is because in Python, a list is created by placing all the items (elements) inside square brackets [], separated by commas. It can have any number of items and they may be of different types (integer, float, string etc.). In this case, the names are string types and they are correctly placed inside quotes "".

This problem has been solved

Similar Questions

Which of these code snippets will return the name "Harry" from the following list ?nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]AnameList()BnameList[1]CNameList(4)DnameList["4"]

Assume that you have a Python list named 'players'.What is the correct Python statement to be used if you need to add the player name 'Bob' to the above list?players.add("Bob")player.append("Bob")players.append("Bob")players.addend("Bob")

Create and print a linked list with four (4) elements. The first letter of your last name will be the basis of the required values for your linked list.

Which of the following is the correct Python syntax for printing all of the items in the names list?names = ["Seb", "Joseph", "Meeyeon", "Anna"]

Which of the following is correct for creating a name tuple ?Atup = ('physics', 'chemistry', 1993, 2017)Btup = ['physics', 'chemistry', 1993, 2017]Ctup = {'physics', 'chemistry', 1993, 2017}Dtup = /'physics', 'chemistry', 1993, 2017/

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.