6.9k views
0 votes
Use the following initializer list:

w = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm", "Functionality", "Viruses"]

Create a second list named s . Then, using a for loop, store the lengths of each word in the list above. In a separate for loop, print — on separate lines — the index followed by the word and the length of the word. Follow the same format as the sample run below.

Sample Run
0: Algorithm, 9
1: Logic, 5
2: Filter, 6
3: Software, 8
4: Network, 7
5: Parameters, 10
6: Analyze, 7
7: Algorithm, 9
8: Functionality, 13
9: Viruses, 7

User Deatrice
by
8.8k points

1 Answer

6 votes

Answer:

Here's the code to create the second list and store the lengths of each word in the first list:

w = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm", "Functionality", "Viruses"]

s = []

for word in w:

s.append(len(word))

And here's the code to print the index, word, and length on separate lines:

for i in range(len(w)):

print(f"{i}: {w[i]}, {s[i]}")

Output:

0: Algorithm, 9

1: Logic, 5

2: Filter, 6

3: Software, 8

4: Network, 7

5: Parameters, 10

6: Analyze, 7

7: Algorithm, 9

8: Functionality, 13

9: Viruses, 7

Step-by-step explanation:

User Farhad Rubel
by
8.6k points