Build a Planet Class - Build a Planet Class

Tell us what’s happening:

Please help. Why I can not pass the 5th and 6th requests?

Your code so far

class Planet:
    def __init__(self, name, planet_type, star):

        if not name or not planet_type or not star:
            raise ValueError('name, planet_type, and star must be non-empty strings')
        if not (isinstance(name, str) and isinstance(planet_type, str) and isinstance(star, str)):
            raise TypeError('name, planet type, and star must be 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('Earth','',34)
planet_2 = Planet('Mars','unknown','sun')
planet_3 = Planet('Venus','unk','sun')

print(planet_1)
print(planet_1.orbit())

print(planet_2)
print(planet_2.orbit())

print(planet_3)
print(planet_3.orbit())

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Planet Class - Build a Planet Class

solved…
the problem is:

  1. that condition will only raise an error if ALL are not strings at once.
  2. I checked empty-string first, then checked the data type, so if the input is 0 (it means falsy), immediately gets a ‘ValueError’, even though what the test asks for is a ‘TypeError’ because 0 is not a string.