Mini project: event registration

Combine strings, lists, dictionaries, functions, and conditions in a small event registration example.

This example combines several beginner concepts. It stores registrations in a list, represents each registration as a dictionary, and uses a function to validate and add a name.

Register a participant

python · static example

attendees = []

def register(name, event):
    clean_name = name.strip()
    if not clean_name:
        return "Name is required"
    attendees.append({"name": clean_name, "event": event})
    return f"{clean_name} registered for {event}"

print(register("Asha", "Python Meetup"))
print(len(attendees))

`strip()` removes surrounding whitespace. This simple example keeps data in memory; it does not save registrations to a database.

Sample output
Asha registered for Python Meetup
1

Labeled sample only — nothing was run on this page.

Case study

Scenario

A society is collecting signups for a Python workshop. Some students may submit a blank name, and the team wants to count successful signups.

Task

How would you reject a blank name and keep track of registrations?

Explanation / example

Check `name.strip()` before adding a record. If it is empty, return an error message; otherwise append a dictionary to `attendees`. Use `len(attendees)` to count the saved records.

Knowledge check

What does `attendees.append(record)` do?

Pick an answer to check.