0

how to delete last printed line in python for example

s = 'abc'
for c in s:
    print(c)

it get

a
b
c

I want

a
b

Is there any way except s[:-1] or if c!= 'c' or it is the only way to get the answer

The method of using two ANSI escape codes LINE_UP = '\033[1A' LINE_CLEAR = '\x1b[2K' is not success

Ben
  • 141
  • 8

0 Answers0