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 556473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:55:24+00:00 2026-05-13T11:55:24+00:00

I know this is probably an easy question but after reviewing the documentation for

  • 0

I know this is probably an easy question but after reviewing the documentation for python 2.6.4 I cannot seem to find out what is wrong. This is my file, in it’s entirety. The problem I am having is in get_phone_number(). After asking for the amount of phone numbers, I get this error:

Traceback (most recent call last):
  File "/home/charles/workspace/HelloWorld/hello.py", line 27, in <module>
    c.get_phone_number()
  File "/home/charles/workspace/HelloWorld/hello.py", line 17, in get_phone_number
    self.phone_number[phone_count]
AttributeError: Contact instance has no attribute 'phone_number'

It seems that I am able to define an attribute on the fly, but not if it is a list? Please help!

class Name():
        def get_name(self):
            self.first = raw_input("First Name?\n")
            self.middle = raw_input("Middle Name?\n")
            self.last = raw_input("Last Name?\n")
        pass
    class Address():
        def get_address(self):
            self.street = raw_input("Street?\n")
            self.city = raw_input("City?\n")
            self.zip = raw_input("Zip Code?\n")
        pass
    class Phone_Number():
        def get_phone_number(self):
            count = 0
            phone_count = raw_input("How many phone numbers?\n")
            self.phone_number[phone_count]
            while count < (phone_count - 1):
                self.phone_number[phone_count] = raw_input("Phone Number: ")
                phone_count -= 1
        pass
    class Contact(Name, Address, Phone_Number):
        pass
    c = Contact()
    c.get_name()
    c.get_address()
    c.get_phone_number()
  • 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-13T11:55:24+00:00Added an answer on May 13, 2026 at 11:55 am

    Your code contains quite a few errors and is not Pythonic. Some points: you need to convert the first user input to an integer. You can use a for loop instead of a while loop. On Python 2.5 you can use xrange instead of range but for Python 3.0 use range. Use append to add an item to a list.

    class Phone_Number():
        def get_phone_numbers(self):
            phone_count = int(raw_input("How many phone numbers?\n"))
            self.phone_numbers = []
            for _ in range(phone_count):
                self.phone_numbers.append(raw_input("Phone Number: "))
    
    p = Phone_Number()
    p.get_phone_numbers()
    for phone_number in p.phone_numbers:
        print phone_number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.