Tell us what’s happening:
I have done pretty much everything that’s been asked, but still couldn’t pass the test cases. It’s even giving the output what was asked for, yet it’s failing in 18th step.
Your code so far
class Planet:
def __init__(self, name, planet_type, star):
if not isinstance(name, str) or not isinstance(planet_type, str) or not isinstance(star,str):
raise TypeError("name, planet type, and star must be strings")
if len(name) == 0 or len(planet_type) ==0 or len(star) ==0 :
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("Jupiter", "Gas giant", "Sun")
planet_2 = Planet("Earth", "Terrestrial", "Sun")
planet_3 = Planet("Proxima Centauri b", "Exoplanet", "Proxima Centauri")
print(str(planet_1))
print(planet_1.orbit())
print(str(planet_2))
print(planet_2.orbit())
print(str(planet_3))
print(planet_3.orbit())
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0
Challenge Information:
Build a Planet Class - Build a Planet Class