Python: Create multiple lists
Create Multiple Lists
Write a Python program to create multiple lists.
Sample Solution:
Python Code:
# Create an empty dictionary named 'obj'
obj = {}
# Iterate through the range of numbers from 1 to 20
for i in range(1, 21):
# Create an empty list as the value and associate it with the string representation of the number 'i' as the key in the dictionary 'obj'
obj[str(i)] = []
# Print the resulting dictionary 'obj'
print(obj)
Sample Output:
{'1': [], '8': [], '14': [], '5': [], '17': [], '9': [], '2': [], '7': [], '16': [], '19': [], '4': [], '18': [], '13': [], '3': [], '15': [], '11': [], '20': [], '6': [], '12': [], '10': []}
Flowchart:
Python Code Editor:
Previous: Write a Python program to split a list based on first character of word.
Next: Write a Python program to find missing and additional values in two lists.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics