47.7k views
4 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

1 Answer

2 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 Divya Konda
by
3.5k points