+ 5

Can someone find the buck?

Hi all I created a small function. Problem is, It returns 0 where I expect something else. I checked and checked and also modified the code few times, but I don’t see the buck. Now I am not sure if it’s me or the code ;) https://code.sololearn.com/cG13rnCpbYmm/?ref=app

13th Oct 2019, 6:03 AM
cocktus
cocktus - avatar
7 Answers
+ 5
In line 8 add task[i] == 'X' after or
13th Oct 2019, 6:07 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 4
Programming errors are called bugs and not bucks.
14th Oct 2019, 8:46 AM
Sonic
Sonic - avatar
+ 3
Thanks for the fast help. now it does what I expect! https://code.sololearn.com/cCgf53zrWCWV/?ref=app
13th Oct 2019, 6:17 AM
cocktus
cocktus - avatar
+ 3
thanks for the lesson... next time I will remember the difference 👍
13th Oct 2019, 8:32 AM
cocktus
cocktus - avatar
+ 2
if you want a more elegant solution, you can also do it like this. task = list('2=6+8X') print(task) # returning the position of 'x' def findx(): for i in range(len(task)): if task[i] in ['x', 'X']: return i print(findx())
14th Oct 2019, 12:47 AM
Shen Bapiro
Shen Bapiro - avatar
+ 1
yes, we got that already.
14th Oct 2019, 7:55 PM
cocktus
cocktus - avatar