Ask coding questions

← Back to all posts
Adding an ID to student name list
SakuraKimiko

Hello

I am trying the following code and to do the follows in PYTHON CODE

  1. I want to start adding student by starting a blank list along with auto generated student ID i.e when once the students joins the site or program, a student no is generated e.g 001 and when the next student joins in , his or her id will become 002 meaning the ID's are generated in series.
  2. How can once create user id using python coding. e.g. once you are joining the program and they ask for personal information. Once the user himself or herself provides a user id (when asked i.e userid=input(""Your user id is:- ")). Can that ID be used to login rather than the name itself

  3. What would be the coding when two people have the same name or user id

Kindly reply all of the above questions in python (as much as possible) because currently I am only learning python.

Thank You for your time

Sakura

Voters
malikkid123
ProCoder123
SakuraKimiko
Comments
hotnewtop
teymour

You might want to use an SQL database to achieve this – they come with handy features that make life easier and are highly performant.
1. If you want to use a python list then whenever a new student is created an ID could be provisioned using len(student_list) (where student_list is the list that you're storing the student data in). It makes sense to store the student data as a dictionary, so your student list might look like:

  1. You can do a linear search to find the student.
  1. You should make sure that this can't happen.
SakuraKimiko

@CaptainAnon

Thank you for your prompt response, Can you kindly tell me where exactly can we apply the 1st code i.e student_list = {[ id:...}] in the following code

blank student list

student_list=[{"Name":}]

student_list= [{"":[]}]

welcome to the site

print ("***Welome***")

#ask if he or she is a student

already_student=("Are you a member:- ")

if already_student=="YES" or already_student=="yes" or already_student=="Yes" or already_student=="Y" or already_student=="y":

else:

do you wish to become a memeber

member=input("Do you wish to become a member:- ")

if member=="YES" or member=="yes" or member=="Yes" or member=="Y" or member=="y":

enter age

student id generator

greet new student and inform of their id

print ("Welcome", name, "Your student ID is ", ID)

thank you again for your time

teymour

@SakuraKimiko

SakuraKimiko

@CaptainAnon

Thank you very much

You have been most helpful

teymour

@SakuraKimiko You're welcome.