+ 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
7 Respuestas
+ 5
In line 8 add task[i] == 'X' after or
+ 4
Programming errors are called bugs and not bucks.
+ 3
Thanks for the fast help. now it does what I expect!
https://code.sololearn.com/cCgf53zrWCWV/?ref=app
+ 3
thanks for the lesson...
next time I will remember the difference 👍
+ 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())
+ 1
yes, we got that already.