This Python program receives a list of groups and displays:
- The total number of groups
- The names of groups that appear on the timeline (based on activity timestamps)
For simplicity, the data is structured as a list of dictionaries containing group names and timestamps.
# Sample list of groups with timestamps
groups = [
{"name": "Math Group", "timestamp": "2025-09-30 10:00"},
{"name": "Physics Group", "timestamp": "2025-09-30 11:30"},
{"name": "Programming Group", "timestamp": "2025-10-01 09:15"},
]
# Count total groups
group_count = len(groups)
# Extract timeline group names
timeline_groups = [group["name"] for group in groups]
# Display results
print(f"Total number of groups: {group_count}")
print("--- Timeline Groups ---")
for name in timeline_groups:
print(name)
Total number of groups: 3
--- Timeline Groups ---
Math Group
Physics Group
Programming Group
- The data is defined as a list of dictionaries with group names and timestamps
- len() is used to count the total number of groups
- A list comprehension extracts the names of all timeline groups
- The output is printed in a clean, readable format