[Solved] python, count characters in last line string [closed]
Split the string from the end(str.rsplit) only once and get the length of last item: >>> s = “””AAAAAAA BBBB CCCCC DDD””” >>> s.rsplit(‘\n’, 1) [‘AAAAAAA\n BBBB\n CCCCC’, ‘ DDD’] #On the other hand simple str.split will split the string more than once: >>> s.split(‘\n’) [‘AAAAAAA’, ‘ BBBB’, ‘ CCCCC’, ‘ DDD’] Now simply get … Read more