Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Create a list with the names of your group members as string literals. It should look similar to example_list1. group_members =[] # YOU FILL
\# 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 =[1] \# YOU FILL THIS IN \# Use indexing to print your own name from group_members. The output should look like: I am John Smith print(") Y YOU FILL THIS IN My group members are: Let's look at how lists can be updated. Using the list in the next code box, we can update the values with the following methods. \#use this list! elements_list = ["earth", "air", "fire", "water"] Replacing: Replace a value at index i by overwriting the variable assignment. In the next code box, replace "fire" with "lightning" and output the resulting list. Hint: Use the index function to find where the string is in the list and then use the notation to access and replace the value at that index. This frees you from finding the index manually. \# Replace fire with lighting here. Be sure to run the code cell above to have elements_list defined \# so that it can be recognized by your code. \# 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 =[1] \# YOU FILL THIS IN \# Use indexing to print your own name from group_members. The output should look like: I am John Smith print(") Y YOU FILL THIS IN My group members are: Let's look at how lists can be updated. Using the list in the next code box, we can update the values with the following methods. \#use this list! elements_list = ["earth", "air", "fire", "water"] Replacing: Replace a value at index i by overwriting the variable assignment. In the next code box, replace "fire" with "lightning" and output the resulting list. Hint: Use the index function to find where the string is in the list and then use the notation to access and replace the value at that index. This frees you from finding the index manually. \# Replace fire with lighting here. Be sure to run the code cell above to have elements_list defined \# so that it can be recognized by your code
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