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

  • SEARCH
  • Home
  • 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 3850594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:02:01+00:00 2026-05-19T17:02:01+00:00

Hey I am very new to python but I am trying to make a

  • 0

Hey I am very new to python but I am trying to make a simple registration system. I would like to be able to have a function update when I add a member but I cannot figure out how. As you will see in the code below, once I am finished adding a member in menu option 2, when I go back and try menu option 1 the member I have just added does not show up. How do I make the show_members function reload the updated dictionary?

In addition to my above question, any advice on ways to improve the below code would be welcome. And yes I know that it is very incomplete but it is a WIP.

import sys
import shutil
import os

tmp = os.path.isfile("members.py.tmp")
if tmp == True:
    os.remove("members.py.tmp")
shutil.copyfile("members.py", "members.py.tmp")

from members import members

def show_menu():
    os.system("clear")
    print "\n","*" * 12, "MENU", "*" * 12
    print "1. List members"
    print "2. Add member"
    print "3. Delete member"
    print "99. Save"
    print "0. Abort"
    print "*" * 28, "\n"
    return input("Please make a selection: ")

def show_members(members):
    for keys in members.keys():
        os.system("clear")
        print "\nNames", "     ", "Code"
        print keys, " - ", members[keys]

def add_member(members):
    os.system("clear")
    name = raw_input("Please enter name: ")
    code = raw_input("Please enter code: ")
    members[name] = code
    return members


#with open("foo.txt", "a") as f:
#     f.write("new line\n")

running = 1

while running:
    selection = show_menu()
    if selection == 1:
        show_members(members)
        print "\n> " ,raw_input("Press enter to continue")
    elif selection == 2:
        add_member(members)
        print "\n> " ,raw_input("Press enter to continue")
    elif selection == 99:
        shutil.copyfile("members.py.tmp", "members.py")
    elif selection == 0:
        os.remove("members.py.tmp")
        sys.exit("Program Aborted")
    else:
        os.system("clear")
        print "That is not a valid option!"
        print "\n> " ,raw_input("Press enter to continue")
  • 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-05-19T17:02:02+00:00Added an answer on May 19, 2026 at 5:02 pm

    In this code:

    if selection == 2:
        add_member(members)
    

    you are returning members, but not doing anything with the return value.

    Easiest thing to do is change it to:

    if selection == 2:
        members = add_member(members)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I am very new to Web Programming. I have been learning PHP from
Hey all, I am trying to accomplish something very simple yet getting an error
Hey all i am VERY new to a Oracle DB and i am trying
Hey guys. This is a very simple question, I'm sure, but I'm getting myself
Hey, I am so close to fininshing my guess a number game, very simple
Hey guys, I am very new to AJAX and and working on a rating
Hey, I am very new to entity, sql, c#, and asp.net so this might
Hey, I'm very new to Ruby and Rails. I was wondering if I was
Hey there guys and gals. I'm very new to php and am following various
Hey Guys I would very much appreciate some help with the following. We're using

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.