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 trialdididadaya Zhao
1,319 Pointslogical operator
Need a bit help, thanks so much!
def check_speed(car_speed)
# write your code here
if (car_speed > 40) && (car_speed < 50)
return "safe"
else
return "unsafe"
end
1 Answer
Luke Pettway
16,593 PointsYou have two problems going on within your code:
1)You want to make sure car_speed is greater than OR equal to 40 and car_speed is less than OR equal to 50
def check_speed(car_speed)
# write your code here
if (car_speed >= 40) && (car_speed <= 50)
return "safe"
else
return "unsafe"
end
2)Your if statement is missing the end clause.
def check_speed(car_speed)
# write your code here
if (car_speed >= 40) && (car_speed <= 50)
return "safe"
else
return "unsafe"
end
end
dididadaya Zhao
1,319 Pointsdididadaya Zhao
1,319 PointsHi luke, thanks, it's right answer, however i tried to run it on work file, it was not functional.
Luke Pettway
16,593 PointsLuke Pettway
16,593 PointsWhen you say that you tried to run it on a work file, could you elaborate a little more as to where you were running the code as well as what was expected vs what actually happened? Thanks.