Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Missing Postional Arguments
#1
I am making an accommodation program and I ran into this error.I saw other threads with the same issue om the site but they didn't help me figure it out. I am running into the error after I search the realtor file for a match. That is the login part of the program, when a student logs in.

This is my main file:
from classes.users import Student, Realtor
import csv

# declaration of files
students_file = "students.txt"
realtor_file = "realtor.txt"


def main():
    prompt()
    option_select()


def prompt():
    print("Welcome to Mason Real Estate")
    print("Please Login or Create Account")


# selection to crete account or login
def option_select():
    print("1. Create Account \n2. Login\n")

    user_choice = int(input("What would you like to to today?: "))

    if user_choice == 1:
        create_user()
    elif user_choice == 2:
        login_user()


# choice to create student or realtor account
def create_user():
    print("Are you a student or realtor?")
    print("1. Student \n2. Realtor\n")
    role = int(input("You are: "))
    if role == 1:
        is_student()
    elif role == 2:
        is_realtor()


# choice to lgin student or realtor
def login_user():
    print("Student or Realtor?")
    print("1. Student \n2. Realtor\n")
    login_type = int(input("You are: "))
    if login_type == 1:
        student_login()
    elif login_type == 2:
        realtor_login()


# when create account is student
def is_student():
    print("\nPlease complete the following: ")
    user = Student(input("Username: ").capitalize(),
                   input("Phone: ").capitalize())
    # call method from student class
    user.create_account(user.username, user.phone)


# when crete acount is realtor
def is_realtor():
    print("\nPlease complete information about yourself and you r rental: ")
    user = Realtor(input("Username: "),
                   input("Phone number: "),
                   input("City: "),
                   input("Suburb: "),
                   input("Rooms: "))
    # call method from realtor class
    user.create_account(user.username, user.phone_number, user.city, user.suburb, user.rooms)


def student_login():

    found = False
    print("\nPlease login")
    while not found:
        # imput of details to login
        name = input("Enter your name: ").capitalize()
        phone = input("Number: ").capitalize()
        # open student file
        with open(students_file, 'r') as all_students:
            student_data = csv.reader(all_students)

            for student in student_data:
                # check if input has matches in file
                if (name and phone) in student:
                    print("\nWelcome " + name.capitalize())
                    search_apartment()
                    found = True
                    break
                else:
                    print("User not found. Try again")
                    break
        all_students.close()


def realtor_login():
    pass


def search_apartment():
    print("What kind of a place would you like?: ")
    find = Realtor(input("What city?: ").capitalize(),
                   input("What suburb?: ").capitalize(),
                   input("How manny room?: ").capitalize())

    find.apartment_info(find.city, find.suburb, find.rooms)


main()
This is where my classes are:
import csv
WRITE = 'w'
APPEND = 'a'
READWRITE = 'w+'


# class for students
class Student:
    def __init__(self, username, phone):
        self.username = username
        self.phone = phone

    # method to create student account
    def create_account(self, username, phone):
        self.username = username
        self.phone = phone

        # create syudent file and append it
        students_file = "students.txt"

        file = open(students_file, mode=APPEND)
        file.write(username + "," + phone + "\n")
        file.close()
        print("\nThank You. Your Account has been created successfully")


# realtor class
class Realtor:
    def __init__(self, username, phone_number, city, suburb, rooms):
        self.username = username
        self.phone_number = phone_number
        self.city = city
        self.suburb = suburb
        self.rooms = rooms

    # method to create realtor account
    def create_account(self, username, phone_number, city, suburb, rooms):
        self.username = username
        self.phone_number = phone_number
        self.city = city
        self.suburb = suburb
        self.rooms = rooms

        # create realtor file and append to it
        realtor_file = "realtor.txt"

        file = open(realtor_file, mode=APPEND)
        file.write(username + "," + phone_number + "," +
                   city + "," + suburb + "," + rooms + "\n")

        print("\nThank You. Your Account has been created successfully")

    def apartment_info(self, city, suburb, rooms):
        self.city = city
        self.suburb = suburb
        self.rooms = rooms

        realtor_file = "realtor.txt"

        # open realtor file
        with open(realtor_file, 'r') as all_realtors:
            realtor_data = csv.read(all_realtors)
            # check if searched parameter exist in the file
            for realtor in realtor_data:
                if (city and suburb and rooms) in realtor:
                    print("Found")

        all_realtors.close()

    def apart_info(self):

        return '{} {} {}'.format(self.city, self.suburb, self.rooms)
And the error:
Traceback (most recent call last):
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 112, in <module>
    main()
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 11, in main
    option_select()
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 28, in option_select
    login_user()
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 48, in login_user
    student_login()
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 90, in student_login
    search_apartment()
  File "C:/Users/Jacques/PycharmProjects/Mason_Housing/main.py", line 107, in search_apartment
    input("How manny room?: ").capitalize())
TypeError: __init__() missing 2 required positional arguments: 'suburb' and 'rooms'
I have been trying to locate where I left an argument but I don't see where it is. Would you please show me what I am supposed to do

Thank you
Reply


Messages In This Thread
Missing Postional Arguments - by Psypher1 - Nov-12-2019, 07:20 PM
RE: Missing Postional Arguments - by ichabod801 - Nov-12-2019, 09:16 PM
RE: Missing Postional Arguments - by Psypher1 - Nov-13-2019, 09:32 AM
RE: Missing Postional Arguments - by ichabod801 - Nov-13-2019, 03:21 PM
RE: Missing Postional Arguments - by Psypher1 - Nov-14-2019, 12:15 PM
RE: Missing Postional Arguments - by ichabod801 - Nov-14-2019, 01:26 PM
RE: Missing Postional Arguments - by Psypher1 - Nov-15-2019, 04:31 PM
RE: Missing Postional Arguments - by ichabod801 - Nov-15-2019, 04:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: missing 3 required positional arguments: wardancer84 9 11,075 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: max_value() missing 2 required positional arguments: 'alpha' and 'beta' Anldra12 2 4,251 May-15-2021, 04:15 PM
Last Post: Anldra12
  TypeError: add() missing 2 required positional arguments NectDz 5 13,210 May-28-2020, 02:54 PM
Last Post: BitPythoner
  Missing 2 Required Positional Arguments: SwiftWater 1 20,035 Feb-28-2019, 08:57 AM
Last Post: buran
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,908 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020