Stuck on this code problem

Hello! I am doing a problem that reads:

Complete the method that takes a boolean value and return a "Yes" string for true, or a "No" string for false. NOTE: I am not looking for the answer — I just want to know why the syntax is wrong (: I’m really trying to do this on my own. Thanks for your assistance.

def bool_to_word(boolean):
    if (boolean === true) {
    return "Yes";
} else if (boolean === false) {
    return "No";

Traceback (most recent call last):
  File "/workspace/default/", line 2, in <module>
    from solution import bool_to_word
  File "/workspace/default/", line 2
    if (boolean === true) {
SyntaxError: invalid syntax

Hi, can you share a link for challenge please?

Sure! My apologies! I figured the entire problem pasted here would be enought; I always forget to provide everything for people to assist lol

So this is Python?
From the first look of your code I thought this is JS… I am little confused)

def >>>> its from python

all this brackets >>>>> definitely JS

Looks like you might need to first study some basic Python before trying to solve challenges. You are not using Python syntax through your code.

Ultimate facepalm emoji. Wow

You forgot to switch to JS, right?) I mean in the codewars interface)

well darn! It’s still wrong.

function boolToWord( bool )
    if (bool === true) {
    return "Yes";
} else if (bool === false) {
    return "No";

Why is the solution like this below and what I had was wrong?

function boolToWord( bool ){
  if (bool) {
    return 'Yes';
  } else {
    return 'No';
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.