Python Forum
Run a Function?: Trouble with Online Python Course
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run a Function?: Trouble with Online Python Course
#2
This part is not correct
    return "{} (health: {})".format(self.name, self.health)
    def __str__(self):
        pass
the __str__ method should return a string
change it to
    def __str__(self):
        return "{} (health: {})".format(self.name, self.health)
Then create an instance of Pichu and print it
pichu = Pichu()
print(pichu)
Output:
Pichu (health: 30)
Reply


Messages In This Thread
RE: Run a Function?: Trouble with Online Python Course - by Yoriz - Aug-18-2022, 08:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Online Python Editor a_k93 4 900 Mar-27-2025, 07:21 AM
Last Post: coolwholesales
  Trouble with installing python domingo251 2 1,523 Sep-23-2023, 12:03 AM
Last Post: ICanIBB
Question Embedding a python file online Dreary35 0 2,024 Jun-10-2021, 05:05 PM
Last Post: Dreary35
  python doc edit and run online? luckrill 0 2,162 Jul-09-2020, 01:28 PM
Last Post: luckrill
  Online python repl? Gribouillis 4 63,627 Apr-09-2020, 12:19 PM
Last Post: Gribouillis
  Trouble with list function Eggman72 2 2,632 Mar-23-2020, 09:36 PM
Last Post: Eggman72
  Using online python for course, How do I open a File that's a link? WhatsupSmiley 1 3,186 Mar-20-2020, 06:56 AM
Last Post: buran
  New to python, having trouble with an exercise Salkay 3 3,210 Feb-18-2020, 01:42 AM
Last Post: Salkay
  More Python Embedding Trouble jibarra 3 4,056 Jul-11-2019, 09:25 PM
Last Post: Gribouillis
  Trouble on importing function from astropy library samsonite 4 5,125 Mar-21-2019, 12:18 PM
Last Post: samsonite

Forum Jump:

User Panel Messages

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