0

i know [-1]

but i don't understand [:-1] mean,,

ex)~~{}txt -> Number of births file

ls=() for y in range(1990,2000): filname = "~~{}.txt".format(y) with open ("filename",'r') as f: data=filename.realines() for d in data(): if d[-1]:
d=d[-1]
birth=data.split(",")[2]
cnt += birth ls.append(y,cnt)

with open("birth_year.csv","w") as f: for year,birth in ls: data ="{},{}\n".format(year,birth) f.write

what mean [:-1]???...

I am not good at coding. so,I'd appreciate it if you'd be kind enough to tell me know. thx

  • 1
    Could you please edit the question to format your code? There are some formatting tools in the bar at the top of the text field. This would highly increase readability and make the question easier to understand and answer. – Cesar van der Poel Feb 21 '21 at 16:57
  • Also, you should tag the programming langage you are using. – β.εηοιτ.βε Feb 21 '21 at 17:00
  • This said, I guess what you are looking at is [Understanding slice notation](https://stackoverflow.com/questions/509211/understanding-slice-notation) – β.εηοιτ.βε Feb 21 '21 at 17:01

0 Answers0