Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9093543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:07:44+00:00 2026-06-16T23:07:44+00:00

I have already posted a question today and it had 2 problems on it.

  • 0

I have already posted a question today and it had 2 problems on it. One of which was solved perfectly, then it got a little complicated. So forgive me but I am posting the other question separately as it confused some peeps:

I am new to python so apologies in advance. Any help is much appreciated. I have been stuck on this code for 2weeks now and I have tunnel vision and cannot work it out:

Basically our assignment was to get to grips with Object-Oriented Programming. We unfortunately have to use “get” and “set” which I’ve learnt a lot of people dislike, however, as per our tutor we have to do it like that. We were told tp create a program whereby the user is presented with a screen with 3 options. 1. adding a student. 2. viewing a student and 3. removing a student.. within my AddStudent function I have to ask the user to enter fname Lname age degree studying id number (these are the easy bits) and also module name and grade for each module, I have managed to create a loop whereby it will ask the user over and over to enter modules and corresponding grades and will break from said loop when the user enters -1 into the modulname field. However, when trying saving it to a list named students[] … (which is at the very top of my code above all functions, to apparently make it global) it saves all input from the user re: age name etc but when it comes to saving module names and grades it only saves the last input and not the multiple inputs I need it to. I am unsure if it is within my AddStudent function where it isn’t saving or within my ViewStudent function: Both are below (remember I HAVE to use the GET and SET malarky) 😉

students[] # Global List

def addStudent():
    print 
    print "Adding student..."
    student = Student()
    firstName = raw_input("Please enter the student's first name: ")
    lastName = raw_input("Please enter the student's last name: ")
    degree = raw_input("Please enter the name of the degree the student is studying: ")
    studentid = raw_input("Please enter the students ID number: ")
    age = raw_input("Please enter the students Age: ")

    while True:
        moduleName = raw_input("Please enter module name: ") 
        if moduleName == "-1":
            break
        grade = raw_input ("Please enter students grade for " + moduleName+": ")

    student.setFirstName(firstName) # Set this student's first name
    student.setLastName(lastName)
    student.setDegree(degree)# Set this student's last name
    student.setGrade(grade)
    student.setModuleName(moduleName)
    student.setStudentID(studentid)
    student.setAge(age)
    students.append(student)
    print "The student",firstName+' '+lastName,"ID number",studentid,"has been added to the system."

……………………

def viewStudent():
    print "Printing all students in database : "

    for person in students:
            print "Printing details for: " + person.getFirstName()+" "+ person.getLastName()
            print "Age: " + person.getAge()
            print "Student ID: " + person.getStudentID()
            print "Degree: " + person.getDegree()
            print "Module: " + person.getModuleName()
            print "Grades: " + person.getGrade()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:07:46+00:00Added an answer on June 16, 2026 at 11:07 pm

    your problem is that the module is a single variable you keep changing. instead, make it a list.

    while True:
            moduleName = raw_input("Please enter module name: ") 
            if moduleName == "-1":
                break
            grade = raw_input ("Please enter students grade for " + moduleName+": ")
    

    should be something like

    modules = []
    
    while True:
            moduleName = raw_input("Please enter module name: ") 
            if moduleName == "-1":
                break
            grade = raw_input ("Please enter students grade for " + moduleName+": ")
            modules.append((moduleName, grade))
    

    add a new variable to student which is “Modules” and is a list.

    and then modules will be a list of tuples which are (moduleName, grade) and to display them, change the line in viewstudent from:

            print "Module: " + person.getModuleName()
            print "Grades: " + person.getGrade()
    

    to:

    for module, grade in person.getModules():
           print "Module: " + module
           print "Grades: " + grade
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already posted another question about this, but no one seemed to know
I have a similar situation to this question , which was already posted. Koraktor
i'm back with one more question related to BASS . I already had posted
I have already posted a question about this, but the situation has changed sufficiently
I already posted the following Question got a solution and moving forward I am
I am using a C1ReportViewer control, and have already posted a question on the
I already posted a similar question but i got told to try and solve
I already posted a question regarding it, but at that time I haven't have
This is very similar to a question I have already asked (and had answered)
i have already posted my issue in SO and got an answer but i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.