List operation: Removing an item

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Apr 16 09:31:34 EDT 2006


On Sun, 16 Apr 2006 01:37:44 -0400, Terry Reedy wrote:

> 
> "Miguel E." <miguest66REMOVE at REMOVEyahoo.com> wrote in message 
> news:1243ikb79qbujfc at corp.supernews.com...
>> Hi,
>>
>> I've been (self) studying Python for the past two months and I have had
>> no background in OOP whatsoever.
>>
>> I was able to write an interactive program that randomly selects an item
>> from a list. From a Main Menu, the user has the option to add items to
>> an empty list, show the list, run the random selector, and of course
>> quit the program. The program also complains if a user tries to add an
>> item that is already in the list prompting the user to enter another 
>> item.
> 
> Do you really need the items sorted?  I strongly suspect that a set would 
> work better.  Much easier to randomly add, delete, and check membership.

The OP didn't say anything about having the items sorted.

I think he's trying to learn how to use Python, as he says, and
specifically learn about lists at this moment. Telling him to use sets
isn't going to help him learn about lists.


-- 
Steven.




More information about the Python-list mailing list