Build a Planet Class - Build a Planet Class

Tell us what’s happening:

i cant pass Q.7 - Q.9,
on the line 11 : i tried using (name == ‘’) instead of (len(name) == 0) but the result still same, can you tell me what did i do wrong ?

Your code so far

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

        self.name = name
        self.planet_type = planet_type
        self.star = 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 len(name) == 0 or len(planet_type) == 0 or len(star) == 0:
            raise ValueError('name, planet_type, and star must be non-empty strings')

Your browser information:

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

Challenge Information:

Build a Planet Class - Build a Planet Class

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-planet-class/68e76b1ce8216249d04df670.md at main · freeCodeCamp/freeCodeCamp · GitHub

Have you tried to create instance of the class? There might be some clues what’s happening.

For example add this at the bottom of your code (outside of the Planet class)

planet1 = Planet('', 'planet', 'star')

I’ve try it and got this result :

Capture

i try to make separate [if] for each parameters and it works just fine, i guess its mandatory to make separate [if] function

They don’t need to have separate if for each condition. That result means there’s something not right with the condition checking if every parameter is str.

here not applies only to the first isinstance, that’s why it is not working