• Register
2 votes
51 views

Problem:

I am new in python programming so I am always confused about what is going wrong with my code. Recently I write a code:
class showInformation(object):
 
    def __int__(self, name, age):
        self.name = name
        self.age = age

def showName(self):
    print("Your Name: "+self.name)
def showAge(self):
    print("Your Age: "+self.age)


Info = showInformation("XXX")

Info.showName()

Which gives me following error:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    Info = showInformation("XXX")
TypeError: showInformation() takes no arguments
typeerror: object() takes no parameters

Whats wrong In my code can anyone explain?

10 7 2
6,050 points

1 Answer

1 vote
 
Best answer

Answer:

In your program you should write:

def __int__(self, name, age):

As:

def __init__(self, name, age):

And your code should be like:

class showInformation(object):
 
    def __init__(self, name, age):
        self.name = name
        self.age = age

def showName(self):
    print("Your Name: "+self.name)
def showAge(self):
    print("Your Age: "+self.age)


Info = showInformation("bot", "20")

Info.showName()

Let me know if it is working for you or not.

11 6 4
34,930 points

Related questions

1 vote
1 answer 26 views
26 views
Problem: For a python programm which I wrote I get some error message as: Traceback (most recent call last): File "info.py", line 13, in <module> Info = showInformation("XXX") TypeError: showInformation() takes no arguments typeerror: object() takes no parameters The ... XXX") Info.showName() Is there any problem in my program. What is this error caused by. Can anyone help? Thanks in advance.
asked Apr 29 samhaz 5k points
1 vote
1 answer 51 views
51 views
Problem: Hello everyone, I am trying to create a webscraper which will take links from CSV file and scrape data. but whenever I run this code it says the object of nonetype has no len(). Below is my code: import requests from bs4 import BeautifulSoup import time ... text return data def main(): read_file() datas = parse_data() writedata(datas, "UP_DATA.csv") main() What&rsquo;s going wrong here?
asked Mar 7 Gavin 15.3k points