Question
example_list1 = [Chicago, Champaign, Urbana] You can also use variables instead of literals to create a list. x = Chicago y = Champaign z =
example_list1 = ["Chicago", "Champaign", "Urbana"]
You can also use variables instead of literals to create a list.
x = "Chicago" y = "Champaign" z = "Urbana" example_list2 = [x, y, z]
In this example, example_list1 and example_list2 contain identical contents!
To access a list element, use square brackets and the index of the element. To print "Champaign", we would write:
print(example_list1[1])
# Create a list with the names of your group members as string literals. It should look similar to example_list1. group_members = [] # YOU FILL THIS IN
print("My group members are: ") print(group_members)
# Now try creating a list with variables instead of literals, similar to how we defined x, y, and z in the cell above. group_member1 = '' group_member2 = '' group_member3 = '' group_member4 = '' group_members = [] # YOU FILL THIS IN
# Use indexing to print your own name from group_members. The output should look like: I am John Smith print('') # YOU FILL THIS IN
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started