Another way (depending on your actual needs): If you want to pop the first n characters and save both the popped characters and the modified string:
s = 'lipsum'
n = 3
a, s = s[:n], s[n:]
print(a)
# lip
print(s)
# sum
>>> x = 'lipsum'
>>> x.replace(x[:3], '')
'sum'
Use del
.
Example:
>>> text = 'lipsum'
>>> l = list(text)
>>> del l[3:]
>>> ''.join(l)
'sum'
Example to show last 3 digits of account number.
x = '1234567890'
x.replace(x[:7], '')
o/p: '890'
Source: Stackoverflow.com