Build a Planet Class - Build a Planet Class

Tell us what’s happening:

I try to fulfill the user story 2 point 3 (raise an ValueError) and don’t see my mistake. I let both my solutions in the code. Maybe someone can tell me my problem here.

Thank you in advance!

Your code so far

class Planet:
    def __init__(self, name, planet_type, star):
        if not isinstance(name, str) or isinstance(planet_type, str) or isinstance(star, str):
            raise TypeError('name, planet type, and star must be strings')
        #if not (name or planet_type or star):
        if name == " " or planet_type == " " or star == " ":
            raise ValueError('name, planet_type, and star must be non-empty strings')
        self.name = name
        self.planet_type = planet_type
        self.star = star

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0

Challenge Information:

Build a Planet Class - Build a Planet Class

GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/lab-planet-class/68e76b1ce8216249d04df670.md

Is this condition looking at a value with an empty string or a value with a space in it?

Thank you for your answer!

I also tried it without the space between the quotationmarks and get the same message:

if name == “” or planet_type == “” or star == “”:

        raise ValueError('name, planet_type, and star must be non-empty strings')

“The __init__ method should raise a ValueError with the message name, planet_type, and star must be non-empty strings if the first argument passed in is an empty string.”

This condition needs to be adjusted. Remember that each expression between the or operator is evalulated separately.

As always, thank you for your help!

Now I wonder, why is the second if condition not working (in the lab) because the first isn’t right? I see why I could fulfill the second task about the TypeError. But shouldn’t be the task about the ValueError correct either way?

the tests are passing in an empty string and checking if it raises that specific error

this one triggers the error if planet_type is a string, or if star is a string, if an empty string is being passed in, it is still a string, and the first error is raised