I want to get the last character of the string.
I can print it using len
method to get it BUT I can't compare it to another character while getting it using the VERY SAME method. Now I'll just paste this WTF code here. Please tell me what's going on here.
fields = line.split(';')
last = fields[0]
capacity = fields[1]
region = fields[2]
print(capacity)
print('kek')
print(capacity[len(capacity)-1])
print('even more kek')
while capacity[len(capacity)-1] == '0':
capacity = capacity[1:len(capacity)-2]
last = last[1:len(last)-2]
Now, the output
100000
kek
0
even more kek
Traceback (most recent call last):
File "/home/mekkanizer/Документы/proj/rossvyaz/making_insert_queries.py", line 52, in <module>
while capacity[len(capacity)-1] == '0':
IndexError: string index out of range