Basic write-once behavior
Input
u = create_user('Alice'); u.id = 100; u.id
Output
100
The first assignment sets id to 100; reading returns 100.
Full lesson preview
Implement a write-once attribute on a Python class using a property and a private backing value. The attribute may be assigned only once (including allowing None) and cannot be deleted or reassigned.
Problem statement
Task
Examples
Input
u = create_user('Alice'); u.id = 100; u.id
Output
100
The first assignment sets id to 100; reading returns 100.
Input
u = create_user('Bob'); u.id = 1; (lambda: (setattr(u, 'id', 2), 'ok'))()
Output
AttributeError
A second assignment must raise AttributeError (in real code you'd catch it).
Input format
Output format
Constraints
Samples
Input
assign_id(create_user('Zoe'), 0)
Output
0
0 is a valid value and should be stored and returned.