+ 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 odpowiedzi
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?