if '1' in s:
print(s.index('1'))
when I am running this code, I am getting this output:
0 1 0 0 0 //(input)
2 //(ouput for print(s.index('1'))
0 0 1 0 0 //(input)
4 //(ouput for print(s.index('1'))
0 0 0 1 0 //(input)
6 //(ouput for print(s.index('1'))
0 0 0 0 1 //(input)
8 //(ouput for print(s.index('1'))
———————————————————————————
So I want to understand why is the index being returned as 2,4,6,8 ??
because '1' is at the position 2 4 6 8
You can use .split(' ')
Tell me first what you want when you are passing 1.?
Обсуждают сегодня