33,107 views
37 votes
37 votes
I need help for 8.10 Code Practice: Question 2. Thanks! =D

I need help for 8.10 Code Practice: Question 2. Thanks! =D-example-1
User Kirikaza
by
3.1k points

1 Answer

16 votes
16 votes

vocab = ['Libraries', 'Bandwidth', 'Hierarchy', 'Software', 'Firewall', 'Cybersecurity', 'Phishing', 'Logic', 'Productivity']

# Print the list before sorting

print(vocab)

# Sort the list

for i in range(len(vocab)):

for j in range(i+1, len(vocab)):

if len(vocab[i]) > len(vocab[j]):

vocab[i], vocab[j] = vocab[j], vocab[i]

# Print the list after sorting

print(vocab)

User Giangregorio
by
2.8k points