Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Lyric Abbott
35,595 Pointshelp
Set the return value of the "check_speed" method to the string "safe" depending on the following condition: The speed passed in as an argument is at least 40. The speed passed in as an argument is less than or equal to 50. You should use the "&&" logical operator to accomplish this task.
my code:
def check_speed(param1 car_speed) if car_speed > 39 value1 && car_speed <= 50 value2 return "safe" end end
2 Answers
Aurelien Schlumberger
6,127 PointsNo need to add arguments. You just need to return the string "safe" if the car speed is greater or equal to 40 and less or equal to 50.
def check_speed(car_speed)
# write your code here
if car_speed >= 40 && car_speed <= 50
return "safe"
end
end
Roscoe Coney
13,124 PointsWhy do you have the word "end" written twice?!
Edely Gomes
4,485 PointsThe first "end" is for the if statment. The second one is for closing the check_speed method.