Tell us what’s happening:
I printed the str method for each output and i called the orbit method for each planet so what am i doing wrong?
There is no errors in the console.
And Im pretty sure I followed both the lab instructions and user stories.
Thanks
Your code so far
class Planet:
def __init__(self,name,planet_type,star):
if not isinstance(name, str):
raise TypeError('name, planet type, and star must be strings')
if not isinstance(planet_type, str):
raise TypeError('name, planet type, and star must be strings')
if not isinstance(star, str):
raise TypeError('name, planet type, and star must be strings')
if name == '':
raise ValueError('name, planet_type, and star must be non-empty strings')
if planet_type == '':
raise ValueError('name, planet_type, and star must be non-empty strings')
if star == '':
raise ValueError('name, planet_type, and star must be non-empty strings')
self.name = name
self.planet_type = planet_type
self.star = star
def orbit(self):
return f'{self.name} is orbiting around {self.star}...'
def __str__(self):
return f'Planet: {self.name} | Type: {self.planet_type} | Star: {self.star}'
planet_1 = Planet('Big Blue','Water','Kepler')
planet_2 = Planet('Stormy','Cloudy','Star5180a')
planet_3 = Planet('Earth','Basic','Solar')
print(str(planet_1))
print(Planet.orbit(planet_1))
print(str(planet_2))
print(Planet.orbit(planet_2))
print(str(planet_3))
print(Planet.orbit(planet_3))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Challenge Information:
Build a Planet Class - Build a Planet Class