An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
May 22, 2020 01:37 pm GMT
Original Link: https://dev.to/thepracticaldev/daily-challenge-247-get-planet-name-by-id-164b
Daily Challenge 247 - Get Planet Name By ID
The function is not returning the correct values. Can you figure out why?
def get_planet_name(id): # This doesn't work; Fix it! name="" switch id: case 1: name = "Mercury" case 2: name = "Venus" case 3: name = "Earth" case 4: name = "Mars" case 5: name = "Jupiter" case 6: name = "Saturn" case 7: name = "Uranus" case 8: name = "Neptune" return name
Example
get_planet_name(3)
# should return 'Earth'
Tests
get_planet_name(3)
get_planet_name(8)
get_planet_name(1)
get_planet_name(5)
Good luck!
This challenge comes from jhoffner on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!
Original Link: https://dev.to/thepracticaldev/daily-challenge-247-get-planet-name-by-id-164b
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To