Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We want to take peoples name and store it into a register.
Check if the name is allowed, only English names are allowed.
Add names to a array i.e the register.
And be able to retrieve there name by typing a function retrieve_name(name).
If retrieve name == a string in the array, then return "name is already in the register"


I am new to python and not a experienced programmer so this is my thought process on how i would try to make a register of peoples names. If you think there is a better way to do this then go ahead. Maybe you use objects to create this, if so then thats fine :)

A little bit about me....
I plan on making this more in depth in the future but would like to keep it simple for now so that i can understand it. I am currently working my way through codecademy tutorials on python.
Posted
Comments
Sergey Alexandrovich Kryukov 23-Dec-13 2:39am    
What's wrong with just reading Python documentation? Trying to do some programming before reading the whole manual makes little sense.
—SA

1 solution

There are many ways to do this, but the most adequate way is using a dictionary (also known as "associative array"): http://docs.python.org/2/tutorial/datastructures.html#dictionaries[^].

Here is assume that ultimately you would need to store names as dictionary keys and something else, some information related to names, otherwise such storage would be totally useless. However, if you wanted to store just objects without duplicates, the adequate Python structure would be a set: http://docs.python.org/2/tutorial/datastructures.html#sets[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900