Excercise control flow (review)

Hi Everyone.

i am busy with the ‘space boxer excercise’ at the control flow review lesson.
i have stumbled to something.


print(" 1. Venus 2. Mars 3. Jupiter")
print(" 4. Saturn 5. Uranus 6. Neptune\n")

weight = 185
planet = 1

my code:
if planet == 1:
then: planet = “Venus”
print(weight * 0.91)


1 (my question: i thought i changed the value of planet from 1 to “Venus” but i still
get 1 and not Venus. What is the reason?)

Thanks for clarifying!

HI there, please provide me with a link to the space boxer challenge for further clarity. I may be wrong, someone please correct me if I am, however I do see an error which would explain why you are getting that result.

In your if statement, i believe you do not need to use the “then” and simply run your code with the correct indentation, please view below for correction.

if planet == 1: planet1 = "Venus" print(planet1) print(weight*0.91) elif planet ==2: planet2 = "Mars" #I ended here but please continue with the rest of the #planets following my example above.

If i remember correctly, i believe the exercise gives you the various weights of the planet, since the weights of the plane varies, please put each weight of each planet in the if/elif statement. rather than it being saved as a variable outside the if-statements.


Thanks for replying Max!
you were right.
the then is settled in my head i shouldn’t write it.
the body of the if statement is enough.

( Learn Python 3 | Codecademy)

1 Like