How to remove the last N characters of a string in Python

1 Answer

0 votes
s = "python programming"
 
print(s)
 
N = 3
s = s[:-N]
 
print(s)
 
 
 
 
'''
run:
 
python programming
python programm
 
'''

 



answered Feb 5, 2021 by avibootz
...