+ 1
Getting False instead of True. I'm I missing something?
def expandLevels(score):Â if score<= '100':Â return 'Proceed to level 3'Â if score<= '50':Â return 'Proceed to level 2'Â if score<= '20':Â return 'Back to level 1'Â else:Â return score expandLevels('15')=='Back to level 1'Â False Shouldn't the bool return as True?
7 Answers
0
you have some logical and syntax error:
error-free defintion can be round in the link below đđ»
https://code.sololearn.com/cnZsSz3zPvW4/?ref=app
+ 10
Try using and instead of or
Like so:
if score<= 100 and score > 51:
Also, you probably want to convert or make score an integer rather than a string.
+ 2
aha! thanks jay Nikhil Dhama
got it!
+ 2
penelopy_wahome
1 more suggestion , Try to post your code in the playground section, and share it's link in this section instead of pasting your code here like you did.
+ 2
penelopy_wahome welcome to SL
also go through this post đđ»
https://www.sololearn.com/discuss/1316935/?ref=app
+ 1
Nikhil Dhama okay, will do.
I'n new here, still tryna get my way around. thanks.
0
Alternatively even doing it this way...still returns as False.
def expandLevels(score):Â
if score== '<= 100 or >= 49':Â
return 'Proceed to level 3'Â
elif score== '<=50 or >=20':Â
return 'Proceed to level 2'Â
elif score== '<=19 or >=0':Â
return 'Back to level 1'Â
else:Â
return score
expandLevels('15')=='Back to level 1'Â
False
What might I be missing?