+ 2

How to properly return a boolean

if (x == true){ return true; }else if (x==false){ return false; }

25th Mar 2018, 2:41 AM
Mia Nurjannah
Mia Nurjannah - avatar
7 Réponses
+ 1
that code up will not work because thee is no : after if
27th Mar 2018, 7:23 PM
viswak reddy
viswak reddy - avatar
0
I think we shouldn not use else if , an else should do the job where only two conditions else return false
27th Mar 2018, 7:16 PM
Saif ul Islam
Saif ul Islam - avatar
0
I guess the question is syntax independent
27th Mar 2018, 7:24 PM
Saif ul Islam
Saif ul Islam - avatar
0
i think it works in c language but not in python
27th Mar 2018, 7:26 PM
viswak reddy
viswak reddy - avatar
0
and the question even is not so clear to help
27th Mar 2018, 7:27 PM
viswak reddy
viswak reddy - avatar
0
before writing that first we need to declare what x is
27th Mar 2018, 7:28 PM
viswak reddy
viswak reddy - avatar
0
e = 0 print('0') if not e else print('true')
7th Jun 2018, 12:04 PM
Johannes
Johannes - avatar